When an user enters in a username and password, i am trying to compare this user input with data that is already stored in the database. For the purposes of just trying to get it to work, if the correct username and password are entered the screen should display "Yay" otherwise it should display "No".
Right now whenever a user enters in any information in the login (whether is be correct or not) the screen is just blank. Please advise what needs to be done to fix this, thank you.
To access the login page go to: http://www.montecarlohotel.co.nf/Membership.html Username & Password already in the database: 585791, Password1
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>Search Results</title>
<style type = "text/css">
body{font-size: 300%;}
</style>
</head>
<body>
<?php
$query = "SELECT *
FROM UserAccount
WHERE Username = '$usr' and Password = '$password'";
$usr = $_POST['memberid'];
$password = $_POST['password'];
// Connect to MySQL
if ( !( $database = mysql_connect( "xxxxxxxx", "xxxxxxx", "xxxxxxxx" ) ) )
{
die( "<p>Could not connect to database</p></body></html>" );
}
// open hotel database
if ( !mysql_select_db( "1994715_hotel", $database ) )
{
die( "<p>Could not open Hotel database</p></body></html>" );
}
// query hotel database
if ( !( $result = mysql_query( $query, $database ) ) )
{
print( "<p>Could not execute query!</p>" );
die( mysql_error() . "</body></html>" );
}
for ($counter = 0; $row = mysql_fetch_row($result); ++$counter)
{
if($result['Username'] == $usr && $result['Password'] == $password)
{
print("Yay");
}
else
{
print("No");
}
}
?>
</body>
</html>