Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote