Code:
$username = $_POST['UName'];
$password = $_POST['PWord'];
$query = "SELECT username,pword,usertype FROM user_info WHERE username = '$username' AND pword = '$password'";
$result = mysql_query($query);
From a security perspective, the above code is absolutely not advisable. Crackers can easily gain access to your system using the following password:
Worse, they can even do:
Code:
'; DROP DATABASE user_info; #
The correct usage is:
Code:
$username = $_POST['UName'];
$password = $_POST['PWord'];
$query = "SELECT username, pword, usertype FROM user_info WHERE username = '$username' AND pword = '$password'";
$result = mysql_query(mysql_real_escape_string($query));
The best way to prevent SQL injection attacks, however, is to use PDO Prepared Statements.
Regards,
[ simon.cpu ]