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!");
?>