graham23s Posted July 29, 2007 Share Posted July 29, 2007 Hi Guys, when a user visits my site i was going to have a check box to save username and password, not sure how to go about this, i can make the check box fine but not sure what i would need exactly on the login_check.php <?php include("includes/db_connection.php"); include("includes/constants.php"); $username = trim(strtolower(mysql_real_escape_string($_POST['username']))); $password = trim(strtolower(mysql_real_escape_string($_POST['password']))); if (empty($username) || empty($password)) { echo "Please fill in both fields."; exit; } ## check the user is in the database ############################################### $login_query = "SELECT username,password FROM `membership` WHERE `username`='$username' AND `password`='$password'"; $login_result = mysql_query($login_query) or die (mysql_error()); $is_greater_than_1 = mysql_num_rows($login_result); // was there a user found?...####################################################### if($is_greater_than_1 != 1) { echo "Sorry username and password combination not found."; exit; } else { ## User is logged in so Let's give him a cookie. ################################### setcookie ("member",$username,time()+1957240,"/"); ## a variable to hold the cookie ################################################### $member = $username; ## If cookie failed set a session...################################################ $_SESSION['member'] = 'member'; ## Update Login timer...############################################################ $timer_query = "UPDATE `membership` SET `login`=now() WHERE `username`='$username' AND `password`='$password'"; $timer_result = mysql_query($timer_query) or die (mysql_error()); if ($timer_result) { header("Location:my_account.php"); } } ?> form to remember this data, any advice would be great cheers Graham Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted July 29, 2007 Share Posted July 29, 2007 only way is to create a cookie, that doesnt expire, which i do beleive expires after teh browser is closed. you may be able to selet time rembered for, and then set a cookie expire time for that, or simply make it sooooo far away into teh future, that the person will never expire..... In the file, simply go: if(isset($_COKIE['Set_User) || isset($_COOKIE['set_Pass'])) { etc. gdlk Quote Link to comment 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.