I have created a form with username and password and login button in html. I have created code for php but it is not able to check the condition for login successfull, below is the php code. It is satisfying all conditions except for login successfull. I guess there is some simple mistake in it and i am not able to find it, please help me.
<?php
include_once('db.php');
$username = mysql_real_escape_string( $_POST["username"] );
$password = mysql_real_escape_string( md5($_POST["pass"]) );
if( empty($username) || empty($password) )
echo "Username and Password Mandatory ";
else
{
$sql = "SELECT count(*) FROM users WHERE( username='$username' AND password='$password')";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
if( $row[0] > 0 )
echo "Login Successful";
else
echo "Failed To Login";
}
?>