Reputation: 81
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
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