chocopi Posted May 13, 2007 Share Posted May 13, 2007 When the user tries to login it does not recognise their password. so if they type in their password it does not login but if they leave the password field blank, it does. <?php require_once ('page_header.php'); session_start(); $username = $_POST['username']; $password = md5($_POST['password']); $query = "SELECT * FROM users WHERE username='$username' and password='$password'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = 'Bad Login'; //html code if($_POST){ print ("<font color=\"#ff0000\"> \n"); print ("<center> \n"); echo ("Incorrect Username and Password combination."); print ("</center> \n"); print ("</font> \n"); require_once ('page_footer.php'); } } else { $_SESSION['username'] = '$username'; require_once ('memberspage.php'); } ?> Thanks in advance, ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/51223-solved-n00b-login-problem/ Share on other sites More sharing options...
guyfromfl Posted May 13, 2007 Share Posted May 13, 2007 is the password md5 in the db? Quote Link to comment https://forums.phpfreaks.com/topic/51223-solved-n00b-login-problem/#findComment-252283 Share on other sites More sharing options...
chocopi Posted May 13, 2007 Author Share Posted May 13, 2007 yes it is Quote Link to comment https://forums.phpfreaks.com/topic/51223-solved-n00b-login-problem/#findComment-252284 Share on other sites More sharing options...
chocopi Posted May 13, 2007 Author Share Posted May 13, 2007 ok i found the problem but it looks fine to me if ($raw_password !== $raw_confirm){ echo ("Your passwords must be identical."); require_once ('page_footer.php'); die (""); } else { $password = md5($_POST['raw_password']); } The idea of this is that it validates the raw_password and raw_confirm and if it is true then it sets the md5 of raw_password to $password. But it hasnt worked :'( Quote Link to comment https://forums.phpfreaks.com/topic/51223-solved-n00b-login-problem/#findComment-252302 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 Change !== to != Quote Link to comment https://forums.phpfreaks.com/topic/51223-solved-n00b-login-problem/#findComment-252308 Share on other sites More sharing options...
chocopi Posted May 14, 2007 Author Share Posted May 14, 2007 cheers, is there anything wrong the variable thingy $password = md5($_POST['raw_password']); as the password is being added as 'd41d8cd98f00b204e9800998ecf8427e' which is blank thanks, Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/51223-solved-n00b-login-problem/#findComment-252776 Share on other sites More sharing options...
chocopi Posted May 14, 2007 Author Share Posted May 14, 2007 oh no dont worry i sorted it by changing This: $password = md5($_POST['raw_password']); To: $raw_password = md5($raw_password); $password = $raw_password; And it seems to work Quote Link to comment https://forums.phpfreaks.com/topic/51223-solved-n00b-login-problem/#findComment-252790 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.