Guest User

Untitled

a guest
Apr 25th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. $user = $_POST['user']; // username from form
  2. $password = $_POST['password']; // password sent from from
  3. $hash = md5($password);
  4.  
  5. // query the db for the user and password combo
  6. $userid = query("select id from users where username = '".clean($user)." ' and passowrd = '".clean($hash)."' LIMIT 1";
  7.  
  8. if ($userid !== false) {
  9. // authentication passed
  10. } else {
  11. // auth failed
  12. }
  13.  
  14. // note:
  15. // clean() is is your custom function that escapes mysql input
  16. // query() is your custom function that queries the db, and returns false on a null resultset
  17. // $userid !== false is used instead of $userid != false since the userid may be 0, see "type comparisons"..
Add Comment
Please, Sign In to add comment