Smudly Posted June 18, 2010 Share Posted June 18, 2010 If a username registers, their username's first letter is automatically capitalized and sent to the database. If a user decides to capitalize a second letter in the middle of their username (Ex: McLoven), unless the username is typed with that capitalized letter, I get an error that says "Incorrect Password!". The password is set as an MD5 encryption. Any suggestions on what to do to fix this problem? MySql version: 5.0.91 Here's my Login.php <?php $username = ucfirst($_POST['username']); $password = $_POST['password']; include('inc/connect.php'); if ($username&&$password) { $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; $userid = $row['id']; // $_SESSION['username'] = $username; // $_SESSION['userid'] = $userid; } // check to see if they match if ($username==$dbusername&&md5($password)==$dbpassword) { //echo "You're In! <a href='member.php'>Click</a> here to enter the member page."; session_start(); $_SESSION['username']=$username; $_SESSION['views'] = 0; header('Location:http://www.daobux.com/member.php'); } else echo "Incorrect Password!"; } else die("That user doesn't exist!"); } else die("Please fill out all fields!"); ?> Link to comment https://forums.phpfreaks.com/topic/205118-login-username-issue/ Share on other sites More sharing options...
Pikachu2000 Posted June 18, 2010 Share Posted June 18, 2010 You're getting the username error because of the conditional; if either part of the conditional fails, the error message "Incorrect Password" is echoed. if ($username==$dbusername&&md5($password)==$dbpassword) Link to comment https://forums.phpfreaks.com/topic/205118-login-username-issue/#findComment-1073685 Share on other sites More sharing options...
kratsg Posted June 18, 2010 Share Posted June 18, 2010 Compare strings? Are you trying to compare two strings that could be case-insensitive or are you saying that the passwords don't match because an md5() of a capitalized letter doesn't match what's in the database? http://php.net/manual/en/function.strcasecmp.php Link to comment https://forums.phpfreaks.com/topic/205118-login-username-issue/#findComment-1073688 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.