I am developing a system for a client. I need some suggestions for that. Is this a safe code to prevent sql injection?
$username=$_POST["username"];
$password=md5($_POST["password"]);
$num_rows=mysql_num_rows(mysql_query("select * from table where username='$username' AND password='$password'"));
if($num_rows>0)
{
echo "Logged in";
}
else
{
echo "Incorrect username or password";
}
Thanks in advance for your suggestions. Please elaborate your answer why the above code is unsafe.Thanks please dont negative vote the question if you dont have any answer.