Tje Posted July 14, 2014 Share Posted July 14, 2014 Hi,My login form is running correctly.i want to add remind me function.please help me. <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> <?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/' ); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/289859-how-to-set-remind-me-function-in-login-form/ Share on other sites More sharing options...
ginerjm Posted July 14, 2014 Share Posted July 14, 2014 Sure! In this forum you post your code correctly. Please see my answer to this exact same (confusing) question in the other forum you wrote in. Quote Link to comment https://forums.phpfreaks.com/topic/289859-how-to-set-remind-me-function-in-login-form/#findComment-1484989 Share on other sites More sharing options...
Tje Posted July 15, 2014 Author Share Posted July 15, 2014 (edited) what i really want to do is when user click this remind me check box,system should be remind his email and password 1hour.please help me Edited July 15, 2014 by Tje Quote Link to comment https://forums.phpfreaks.com/topic/289859-how-to-set-remind-me-function-in-login-form/#findComment-1485139 Share on other sites More sharing options...
chrisrulez001 Posted July 17, 2014 Share Posted July 17, 2014 Hi there, TjeOn the login form I have changed the type of the password input box from text to password, this hides the password when the user types it.Login Form: <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 <?php if(isset($_COOKIE['username'])) { echo " value=\"".$_COOKIE['username']."\""; } ?> /><br /> <input type="password" id="pwd1" class="form-control" name="pwd1" placeholder="Password" value=""/><br/> <label class="checkbox"> <input type="checkbox" value="remember" name="remember" <?php if(isset($_COOKIE['remember'])) { if($_COOKIE['remember'] == "remember") { echo " checked=\"checked\""; } } ?>> Remember me </label> <input type="submit" value="Login" onclick="ValidationLog()" style="color:#FFF;" class="btn btn-lg btn-primary btn-block"/> </form> PHP Code: <?php $mail = $_POST['email1']; $pwd = $_POST['pwd1']; $remember = $_POST['remember']; $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/' ); if($remember == "remember") { setcookie("remember", $remember, time()+3600); setcookie("username", $mail, time()+3600); } } } ?> I know you asked for the login form to remember the password for 1 hour, this is not really recommended if the user uses a shared computer as anyone with physical access to the computer can access the users account.Also in the PHP code, you might want to hash or salt the user's password to protect it in the database. This link might help on password hashing: http://php.net/manual/en/faq.passwords.phpYou might want to add some SQL injection prevention (maybe use mysql_real_escape_string()). This link might help on SQL Injection: http://php.net/manual/en/security.database.sql-injection.php Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/289859-how-to-set-remind-me-function-in-login-form/#findComment-1485574 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.