knifeh Posted February 16, 2010 Share Posted February 16, 2010 Hi guys is it possible someone can help me out please. ive been trying to work out whats wrong with this script for a few hours. and still havent got anywhere. When i go to login in it, comes up with what its ment to if a user is not in the db, but it is. <?php require('function.php'); session_start(); connect(); $username = @$_POST['username']; $password = @$_POST['password']; $submit = @$_POST['submit']; if(loggedin()) { die("You are already logged in!"); }else{ if($submit) { if($username&&$password) { $rememberme = $_POST['rememberme']; $password = md5($password); $loginquery = mysql_query("SELECT username FROM users WHERE username='$username'"); $numrows = mysql_num_rows($loginquery); if($numrows) { while($row = mysql_fetch_assoc($loginquery)) { $password1 = $row['password']; } if($password==$password1) { if($rememberme == "on"){ setcookie("username",$username,time()+259200); header("location: index.php"); }else if($remembeme == ""){ $_SESSION['username'] = $username; header("location: index.php"); die; } }else{ echo "user does not exist"; } } }else{ echo "please fill out all of the fields"; } } } ?> <html> <link href="style/main.css" rel="stylesheet" type="text/css" /> <form action="login.php" method="POST"> <table> <tr> <td> Username: </td> <td> <input type="text" name="username" /> </td> </tr> <tr> <td> Password: </td> <td> <input type="password" name="password" /> </td> </tr> <tr> <td> Remember Me: </td> <td> <input type="checkbox" name="rememberme" /> </td> </tr> <tr> <td> <input type="submit" name="submit" value="submit" /> </td> </tr> </table> </form> </body> </html> Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/192249-login-script-comes-up-with-user-does-not-exsist-when-it-does/ Share on other sites More sharing options...
jl5501 Posted February 16, 2010 Share Posted February 16, 2010 There are 2 things that I see as wrong with a quick glance, which may or may not be causing your problem. 1) you are looping through any users with the same username, but only check the password against the last one. 2) you have an inconstant spelling of $rememberme Link to comment https://forums.phpfreaks.com/topic/192249-login-script-comes-up-with-user-does-not-exsist-when-it-does/#findComment-1013116 Share on other sites More sharing options...
PFMaBiSmAd Posted February 16, 2010 Share Posted February 16, 2010 The "user does not exist" message is output when if($password==$password1) is FALSE. Your first step would be to get your indentation under control so that you can see that the logic is not what you think it is. Your next step would be to troubleshoot why the entered password does not match what is in your database table. Echo both values and find out why they don't match. Link to comment https://forums.phpfreaks.com/topic/192249-login-script-comes-up-with-user-does-not-exsist-when-it-does/#findComment-1013118 Share on other sites More sharing options...
knifeh Posted February 16, 2010 Author Share Posted February 16, 2010 ok thanks alot guys i'll see what if i can get it sorted with your advise. thanks again. Link to comment https://forums.phpfreaks.com/topic/192249-login-script-comes-up-with-user-does-not-exsist-when-it-does/#findComment-1013121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.