gwolff2005 Posted April 14, 2009 Share Posted April 14, 2009 Hi guys, I need your help! I have the following code but something is wrong. The remember me function does not work. What did I do wrong? <?php require_once('Connections/Login.php'); ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "intro.php"; $MM_redirectLoginFailed = "login.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_Login, $Login); $LoginRS__query=sprintf("SELECT firstname, name, results, username, password FROM users WHERE username='%s' AND password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $Login) or die(mysql_error()); $row = mysql_fetch_array($LoginRS); // ADDED $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_password'] = $row['password']; $_SESSION['MM_UserGroup'] = $loginStrGroup; $_SESSION['MM_name'] = $row['name']; // CHANGED $_SESSION['MM_results'] = $row['results']; $_SESSION['MM_firstname'] = $row['firstname']; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } if(isset($_POST['remember'])){ setcookie("cookname", $_SESSION['MM_username'], time()+60*60*24*100, "/"); setcookie("cookpass", $_SESSION['MM_password'], time()+60*60*24*100, "/"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style3 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000033; } #Layer1 { position:absolute; left:71px; top:83px; width:473px; height:119px; z-index:1; } #Layer2 { position:absolute; left:71px; top:212px; width:354px; height:17px; z-index:2; } .style5 { font-size: 11px; color: #000033; font-family: Verdana, Arial, Helvetica, sans-serif; font-style: italic; } #Layer3 { position:absolute; left:110px; top:23px; width:245px; height:19px; z-index:3; } #Layer4 { position:absolute; left:71px; top:17px; width:235px; height:19px; z-index:3; } #Layer5 { position:absolute; left:360px; top:14px; width:401px; height:333px; z-index:4; } --> </style> </head> <body> <div id="Layer1"> <form action="<?php echo $loginFormAction; ?>" method="POST" name="form1" target="_top" id="form1"> <table width="400" border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="100" class="style3">Username:</td> <td><div align="left"> <input name="username" type="text" class="style3" id="username" /> </div></td> </tr> <tr> <td width="100"><span class="style3">Password:</span></td> <td><div align="left"> <input name="password" type="password" class="style3" id="password" /> </div></td> </tr> <tr> <td class="style3">Remember me: </td> <td><input name="remember" type="checkbox" id="remember" value="checkbox" /></td> </tr> <tr> <td width="100"> </td> <td><div align="left"> <input name="Submit" type="submit" class="style3" value="Submit" /> </div></td> </tr> </table> </form> </div> <div class="style5" id="Layer2">If you don't have a login, please register <a href="register.php" target="_self">here</a>. </div> <div id="Layer4"><a href="pics/buttonlogin.php"><img src="pics/buttonlogin.jpg" alt="" name="" width="257" height="19" border="0" /></a></div> <div id="Layer5"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="400" height="325"> <param name="flash_component" value="ImageViewer.swc" /> <param name="movie" value="login.swf" /> <param name="quality" value="high" /> <param name="FlashVars" value="flashlet={imageLinkTarget:'_blank',captionFont:'Verdana',titleFont:'Verdana',showControls:true,frameShow:false,slideDelay:5,captionSize:10,captionColor:#333333,titleSize:10,transitionsType:'Random',titleColor:#333333,slideAutoPlay:false,imageURLs:['img1.jpg','img2.jpg','img3.jpg'],slideLoop:false,frameThickness:2,imageLinks:['http://macromedia.com/','http://macromedia.com/','http://macromedia.com/'],frameColor:#333333,bgColor:#FFFFFF,imageCaptions:[]}" /> <embed src="login.swf" quality="high" flashvars="flashlet={imageLinkTarget:'_blank',captionFont:'Verdana',titleFont:'Verdana',showControls:true,frameShow:false,slideDelay:5,captionSize:10,captionColor:#333333,titleSize:10,transitionsType:'Random',titleColor:#333333,slideAutoPlay:false,imageURLs:['img1.jpg','img2.jpg','img3.jpg'],slideLoop:false,frameThickness:2,imageLinks:['http://macromedia.com/','http://macromedia.com/','http://macromedia.com/'],frameColor:#333333,bgColor:#FFFFFF,imageCaptions:[]}" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="400" height="325"> </embed> </object> </div> <div align="center"></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/153984-remember-function-login-page/ Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 this part here... <?php require_once('Connections/Login.php'); ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } should change it to this... <?php // *** Validate request to login to this site. session_start(); require_once('Connections/Login.php'); the session has to be started so you can access $_SESSION. to be honest I've never really seen much use of putting in a remember me feature, as most web browsers can just save the login info anyway, and loginning isn't all that hard when you have to press only 1 button. Link to comment https://forums.phpfreaks.com/topic/153984-remember-function-login-page/#findComment-809361 Share on other sites More sharing options...
gwolff2005 Posted April 14, 2009 Author Share Posted April 14, 2009 Hi MAsterACE, I treid that but there is no difference... ??? What could it be... PS:The remember me is as well for the password, which is quite useful in case you forgot it... Link to comment https://forums.phpfreaks.com/topic/153984-remember-function-login-page/#findComment-809367 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.