Password correct but error message saying its incorrect
<p>I am new to programming and PHP so please bare with me if I am making an obvisous mistake, but I have looked at some other questions which seem to have the same problem but they didnt seem to have the answers which would correct my example. And I cant figure out what is wrong with mine. The password I know is correct but for some reason I am receiving an error saying it is incorrect.</p>

<p>here is my signup.php</p>

<pre><code>$UserName = $_POST['UserName'];
$password = $_POST['password'];
$msd5Password = $md5[$password];
$email = $_POST['email'];


if ($UserName == null || $password == null || $email == null) {
echo 'Please Fill In All The Values';
}
else {
$sql = mysql_query("SELECT * FROM login WHERE email = '$email'");
$numrows = mysql_num_rows($sql);
if($numrows !=0)
{
die("There already is an account created with the email you entered.");
}
else
{
mysql_connect("localhost", "root") or die (mysql_error);
mysql_select_db ("thereview");
mysql_query("INSERT INTO login (UserName, password, email) VALUES       ('$UserName', '$md5Password', '$email')")
or die(mysql_error());
header("Location:login.php");
 }
}
</code></pre>

<p>And here is my login.php</p>

<pre><code>session_start();
$UserName = $_POST['UserName'];
$password = $_POST['password'];

if($UserName == null|| $password == null) {
echo 'Please fill in UserName and Password';
}
else{
mysql_connect("localhost", "root") or die (mysql_error);
mysql_select_db ("thereview");
$query = mysql_query ("SELECT * FROM login WHERE UserName = '$UserName'");

$numrows = mysql_num_rows($query);
if($numrows != 0) {
while($row = mysql_fetch_assoc($query)) {
$dbEmail = $row['email'];
$dbUserName = $row['UserName'];
$dbPassword = $row['password'];
$dbId = $row['id'];
}
if($UserName = $dbUserName &amp;&amp; md5($password) == $dbPassword) {
$_SESSION['UserName'] = $dbUserName;
$_SESSION['email'] = $dbEmail;
}
else {
echo 'UserName or Password is incorrect';
}
}
else {
echo 'User does not exist, Create an Account';
}
}
</code></pre>

<p>Thank you for the help</p>
