I'll pay $20 via PayPal to anyone that can provide a fix for this: I have a website, www.prizetoad.com. I'm getting quite a few reports by members of the inability to login to their members area. The login page is at http://www.prizetoad.com/login.php. What seems to be happening is that after entering their Username and Password, then clicking the "Log Me In" button, the login.php page just refreshes/reloads with the Username and Password fields now empty. This appears to be browser specific, although I can't tell you exactly what all browsers have problems. Might be a combination of the browser and sessions/cookies in my code? User might have cookies turned off? Not really sure. Just need it to work for all users. Anyone wishing to test themselves can login with test account / buckydent. Login.php code is shown below: <?php include('config.php'); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM prize_members WHERE uUserEmail = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['uPassword']) { } else { header("Location:http://www.prizetoad.com/ members.php"); } } } //if the login form is submitted if (isset($_POST['submit']) || isset($_POST['submit_x'])) { // checks if the useremail exists if (!get_magic_quotes_gpc()) { $_POST['useremail'] = addslashes($_POST['useremail']); } //Gives error if user dosen't exist $usercheck = $_POST['useremail']; $check = mysql_query("SELECT * FROM prize_members WHERE uUserEmail = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) { $error_msg = "That Username does not exist in our database. Your Username is the email address you registered with."; } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['uPassword'] = stripslashes($info['uPassword']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['uPassword']) { $error_msg = "Incorrect password, please try again."; } } // if login is ok then we add a cookie if ($error_msg == "") { $_POST['useremail'] = stripslashes($_POST['useremail']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['useremail'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //set Last_Login field $res = mysql_query("UPDATE prize_members SET Last_Login = NOW() WHERE uUserEmail = '$usercheck'"); //then redirect them to the members area header("Location:http://www.prizetoad.com/members.php"); } else { } } ?> <?php include('header.php'); ?> <div class="body"> <div class="content"> <div class="content_top" align="center"> <strong><br /><br /> <span class="style2">MEMBER LOGIN</span><br /></strong> </div> <div class="content_middle" align="center"> <div class="content_middle_text_privacy"> <br /> Not a member yet? - <a href="index.php" style="text-decoration: none;">Click Here To Register</a> <div class="error" align="center"><font color="#ff0000"><?php echo "$error_msg"; ?></font></div> <form name="registrationform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" /> <br /> <div class="name" align="left"> Username:<br /> <div class="form"><input class="textarea" name="useremail" maxlength="60" size="24" type="text" style="border: none;" /></div> </div> <div class="password1" align="left"> Password:<br /> <div class="form"><input class="textarea" name="pass" maxlength="20" size="24" type="password" style="border: none;" /></div> </div> <br /> <!-- <span style="color: #000000; font-size: 9px; text-decoration: underline;"><a href="index.php">Forgot Password? - Click Here</a></span> <br /> <br /> --> <input onclick="return validate();" name="submit" size="20" src="images/login.gif" type="image" value="Log Me In!" width="100" height="25" /> </form> <br /> <br /> </div> </div> <div class="content_bottom" align="right"> Back to <a href="index.php">Homepage</a> </div> </div> </div> <?php include('footer.php'); ?> Code (markup): Thanks, James
Turns out that stephan2307's fix, while helpful, wasn't the solution to my particular problem. Anyone else out there want to give it a try?