Write a PHP function \"checkPass\" that takes two arguments: $user and $password
ID: 3916500 • Letter: W
Question
Write a PHP function "checkPass" that takes two arguments: $user and $password and returns the UserID if the password matches the MD5 encoding of the appropriate password in the interview_user_info table below and -1 otherwise.
The $user variable contains the NetID of the individual; the $password variable contains a clear-text version of the password as submitted.
The connection and database selection are taken care of. Write the query to pull data from the table "interview_user_info", and return the result. The connection will be closed for you.
Hint: You will likely need to make use of the following functions and possibly others: md5, mysql_query, mysql_fetch_assoc
Explanation / Answer
If you have any doubts, please give me comment...
function checkPass($user, $password){
$query = mysql_query("SELECT * FROM interview_user_info WHERE NetID = '".$user."' AND Passwd='".md5($password)."'");
if(mysql_num_rows($query)==1){
$result = mysql_fetch_assoc($query);
return $result;
}
else
return -1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.