Proposing SQL Statement Coverage Metrics: Difference between revisions
Programsam (talk | contribs) |
Programsam (talk | contribs) |
||
| Line 46: | Line 46: | ||
$username = $_POST[‘username’]; | $username = $_POST[‘username’]; | ||
$password = $_POST[‘password’]; | $password = $_POST[‘password’]; | ||
//query the database for a user with username/pw | //query the database for a user with username/pw | ||
$result = mysql_query(“select * from users where username = ‘$username’ AND password = ‘$password’”); | $result = mysql_query(“select * from users where username = ‘$username’ AND password = ‘$password’”); | ||
//extract the first row of the resultset | //extract the first row of the resultset | ||
$firstresult = mysql_fetch_array($result); | $firstresult = mysql_fetch_array($result); | ||
//extract the “role” column from the result | //extract the “role” column from the result | ||
$role = $firstresult[‘role’]; | $role = $firstresult[‘role’]; | ||
//set a cookie for the user with their role | //set a cookie for the user with their role | ||
setcookie(“userrole”, $role); | setcookie(“userrole”, $role); | ||