Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?
  2.  
  3. require_once('../dbconfig.inc');
  4. require_once('../dbconnect.inc');
  5.  
  6. //username and password from form (in plain text)
  7. $myusername = $_POST['myusername'];
  8. $mypassword = $_POST['mypassword'];
  9.  
  10. //hash password with md5
  11. $encrypted_password = md5($mypassword);
  12.  
  13. //protect from mysql injections
  14. $myusername = stripslashes($myusername);
  15. $myusername = mysql_real_escape_string($myusername);
  16.  
  17. $mypassword = stripslashes($encrypted_password);
  18. $mypassword = mysql_real_escape_string($encrypted_password);
  19.  
  20. //compare username and password with db-entry
  21. $sql = "SELECT * FROM $table WHERE username = '$myusername' AND password = '$mypassword'";
  22. $result = mysql_query($sql);
  23.  
  24. $count = mysql_num_rows($result);
  25.  
  26. if ($count == 1)
  27.     //login ok
  28. else
  29.     //login failed
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement