checkit923
checkit923

Reputation: 81

Password is correct, yet I get an incorrect password error

Heres my script, no matter what I do I keep getting incorrect password, please help!

<?php

$email = $_POST['email-field'];
$password = $_POST['password-field'];

if ($email&&$password){ 
   $connect = mysql_connect("xx","xx","xx") or die("Couldnt connect!");
   mysql_select_db(xx) or die("Couldnt find db");

   $query = mysql_query("SELECT * FROM users WHERE email='$email'");
   $numrows = mysql_num_rows($query); 
   if ($numrows!=0){
     while ($row = mysql_fetch_assoc($query)){
        $dbemail = $row['email'];
        $dbemail = $row['password'];
     }

  if ($username==$dbusername&&$md5password==md5($password)) {
      echo "You're in!";
  }else
      echo "Incorrect password";    
}
else
    die("That user doessnt exist!");
}
else
    die("Please enter a username and a password"); 

?>

Upvotes: 0

Views: 235

Answers (3)

Anonymous
Anonymous

Reputation: 572

$dbemail = $row['email'];
$dbemail = $row['password'];

You call those 2 both $dbemail. While in your if statement, you use $dbusername and $md5password.

You should change $row['email'] to $dbusername and $row['password']to $md5password.

$dbusername = $row['email'];
$md5password = $row['password'];

Upvotes: 3

Jeff Watkins
Jeff Watkins

Reputation: 6359

You're assigning dbemail twice rather than md5password.

Upvotes: 0

Steve
Steve

Reputation: 642

You never defined $dbusername nor $password.

Upvotes: 0

Related Questions