squiblo Posted July 23, 2009 Share Posted July 23, 2009 this is my form to login <form name="form1" method="post" action="checklogin.php"> <input type="text" id="myusername" style="position:absolute;left:651px;top:59px;width:174px;font-family:Arial;font-size:13px;z-index:4" size="29" name="myusername" value="" title="username"> <input type="password" id="mypassword" style="position:absolute;left:651px;top:86px;width:174px;font-family:Arial;font-size:13px;z-index:5" size="29" name="mypassword" value="" tabindex="password" title="password"> <input type="checkbox" id="Checkbox1" name="Checkbox1" value="on" style="position:absolute;left:648px;top:113px;font-family:Arial;font-size:13px;z-index:6"> <input type="submit" id="Button1" name="Login" value="Login" style="position:absolute;left:778px;top:117px;width:50px;height:43px;font-family:Arial;font-size:13px;z-index:8" title="Login"> </form> but i don't actually know how to get the "remember me" to work or where to put the script. Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/ Share on other sites More sharing options...
ignace Posted July 23, 2009 Share Posted July 23, 2009 http://be2.php.net/manual/en/function.session-set-cookie-params.php Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881371 Share on other sites More sharing options...
squiblo Posted July 23, 2009 Author Share Posted July 23, 2009 Do i put this code on the page where you login or the profile page when logged in?? void session_set_cookie_params ( int $lifetime [, string $path [, string $domain [, bool $secure= false [, bool $httponly= false ]]]] ) Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881372 Share on other sites More sharing options...
ignace Posted July 23, 2009 Share Posted July 23, 2009 Do i put this code on the page where you login or the profile page when logged in?? void session_set_cookie_params ( int $lifetime [, string $path [, string $domain [, bool $secure= false [, bool $httponly= false ]]]] ) you need to call session_set_cookie_params() for every request and before session_start() is called. Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881374 Share on other sites More sharing options...
mmarif4u Posted July 23, 2009 Share Posted July 23, 2009 you can put a check box in the login, and then check it in login.php code whether its checked or not. If yes then save the details of the user for next time by using cookies on his/her pc. This might help. http://www.w3schools.com/PHP/php_cookies.asp Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881378 Share on other sites More sharing options...
ignace Posted July 23, 2009 Share Posted July 23, 2009 you can put a check box in the login, and then check it in login.php code whether its checked or not. If yes then save the details of the user for next time by using cookies on his/her pc. Please elaborate to which information you are referring? A session cookie has by default a lifetime of 0 (which means it is destroyed upon browser closier). If you modify the lifetime of the session cookie then the session on your server won't expire until the client-side cookie does or until you destroy the session or the browser crumbles the cookie. Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881398 Share on other sites More sharing options...
squiblo Posted July 23, 2009 Author Share Posted July 23, 2009 i do not understand cookies one little bit, even after those guides all i want is to remember the username from mysql, i do not want to remember the password Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881406 Share on other sites More sharing options...
xcoderx Posted July 23, 2009 Share Posted July 23, 2009 Wish i could help u but i cant, post ur login.php here maybe someone would be kind enuf to help u out. Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881408 Share on other sites More sharing options...
squiblo Posted July 23, 2009 Author Share Posted July 23, 2009 login.php <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); if(isset($_POST['Login'])){ // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "profile.php" session_register("myusername"); session_register("mypassword"); header("location:profile.php"); } else { header(""); } } ?> profile.php <?php session_start(); if(!$_SESSION['myusername']){ header("location:index.php"); } ?> <html> <body> Login Successful </body> </html> login form <form name="form1" method="post" action="login.php"> <input type="text" id="myusername" style="position:absolute;left:651px;top:59px;width:174px;font-family:Arial;font-size:13px;z-index:4" size="29" name="myusername" value="" title="username"> <input type="password" id="mypassword" style="position:absolute;left:651px;top:86px;width:174px;font-family:Arial;font-size:13px;z-index:5" size="29" name="mypassword" value="" tabindex="password" title="password"> <input type="checkbox" id="Checkbox1" name="Checkbox1" value="on" style="position:absolute;left:648px;top:113px;font-family:Arial;font-size:13px;z-index:6"> <input type="submit" id="Button1" name="Login" value="Login" style="position:absolute;left:778px;top:117px;width:50px;height:43px;font-family:Arial;font-size:13px;z-index:8" title="Login"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881412 Share on other sites More sharing options...
squiblo Posted July 23, 2009 Author Share Posted July 23, 2009 really confused Quote Link to comment https://forums.phpfreaks.com/topic/167158-remember-me/#findComment-881438 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.