/    Sign up×
Community /Pin to ProfileBookmark

how to set remind me function in login form

Hi,

My login form is running correctly.i want to add remind me function.please help me.

[U]html[/U]

<form class=”form-signin” role=”form” id=”form1″ method=”post” action=”log.php”>
<h2 class=”form-signin-heading text-center bluetxt”>Sign In</h2>
<input type=”text” id=”email1″ class=”form-control” name=”email1″ placeholder=”Email address” autofocus /><br />
<input type=”text” id=”pwd1″ class=”form-control” name=”pwd1″ placeholder=”Password” value=””/><br/>
<label class=”checkbox”>
<input type=”checkbox” value=”remember” name=”remember”> Remember me
</label>
<input type=”submit” value=”Login” onclick=”ValidationLog()” style=”color:#FFF;” class=”btn btn-lg btn-primary btn-block”/>
</form>

[U]PHP[/U]

<?php

$mail = $_POST[’email1′];
$pwd = $_
POST[‘pwd1’];

$con = mysql_connect(“localhost”,”root”,””);
if(!$con)
{
die(‘Could not connect:’.mysql_error());
}
mysql_select_db(“biz”,$con);
if((($mail)&&($pwd))==””){
header( ‘Location:index.php’ );
}else{

$result = mysql_query(“SELECT mail,pw FROM reg WHERE mail = ‘$mail’ AND pw = ‘$pwd'”);
$num_rows = mysql_num_rows($result);
mysql_close($con);
if($num_rows == 0)
{

}
else{
header( ‘Location:user/’ );

}
}

?>

[ATTACH=CONFIG]16209[/ATTACH]

[canned-message]attachments-removed-during-migration[/canned-message]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJul 14.2014 — 1 - please post code properly using the tags as posted in the rules. ('php' and '/php' wrapped in square brackets to start and end your code section.)

2 - please rewrite this code to use mysqli extension or pdo instead of the deprecated MySQL one

3 - your if statement below:
[code=php]

if((($mail)&&($pwd))=="")
{
[/code]


is rather confusing. A simpler statement is:
[code=php]
if (!($mail && $pwd))
{
[/code]

to determine if one or both of the items are missing.

Of even better (IMHO):
[code=php]
if ($mail == '' || $pwd == '')
{
[/code]

to make your intent clearer.

There are several other things wrong with your login approach but your question is really about something else. Whatever do you mean by "reminder"?
Copy linkTweet thisAlerts:
@NogDogJul 14.2014 — In fact, if you want to be really thorough (and I usually do ? ):
[code=php]
if(
!isset($_POST['email1']) or
!isset($_POST['pwd1']) or
trim($_POST['email1']) === '' or
trim($_POST['pwd1']) === ''
) {
header( 'Location:index.php' );
}
else {
$mail = $_POST['email1'];
$pwd = $_POST['pwd1'];
// ... rest of code ...
}
[/code]

?
Copy linkTweet thisAlerts:
@Tje1authorJul 15.2014 — thanks for your advice.what i want to do is when user click this remind me check box,system want to remind his email and password 1hour.please help.

[canned-message]attachments-removed-during-migration[/canned-message]
Copy linkTweet thisAlerts:
@ginerjmJul 15.2014 — You must mean "REMEMBER ME", not remind me.

In that case you could do it with a cookie. One for the remember me checkbox and one for the last userid that signed. Don't save the password though. Set your cookies expiration for as long as you want and then when the login script first runs check if the cookies exist.
×

Success!

Help @Tje1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...