Reputation: 346
Below is the php code. It compares data from the form and with database values.
However when I click the login button it doesn't do anything?
mysql_connect($host, $databaseUsername, $databasePassword) or die(mysql_error());
mysql_select_db("login") or die(mysql_error());;
$uname = $_POST['inputEmail'];
$pword = $_POST['inputPassword'];
$result = mysql_query("SELECT * FROM login
WHERE Usernames='$uname' AND Passowrds='$pword'");
if ($row = mysql_fetch_array($result))
{
echo "correct login information";
} else {
echo "wrong login information";
}
?>
Upvotes: 0
Views: 90
Reputation: 577
try to check if mysql returns any error then check the count of the returned data
if($result = mysql_query("SELECT * FROM login WHERE Usernames='$uname' AND Passowrds='$pword'")){
// $result != false
// count the returned data
echo mysql_num_rows($result);
}
else{
// call mysql_error(); to print out mysql error
echo mysql_error();
}
Upvotes: 0
Reputation: 9329
You are using mysql incorrectly. Use mysqli or PDO with prepared statements beside this you have typo in your query string and i think your environment doesn't send any error messages so turn on error reporting and then you will see what is the problem.
Upvotes: 0