Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. // collect data from form
  2. $user=$_POST['user'];
  3. $pass=$_POST['pass'];
  4.  
  5. // protect from an SQL injection
  6. $user = stripslashes($user);
  7. $pass = stripslashes($pass);
  8. $user = mysql_real_escape_string($user);
  9. $pass = mysql_real_escape_string($pass);
  10.  
  11. //encrypt
  12. $newPass=md5($pass);
  13.  
  14. $sql="SELECT * FROM $tbl_name WHERE username='$user' and password='$newPass'";
  15. $result=mysql_query($sql);
  16.  
  17. // Mysql_num_row is counting table row
  18. $count=mysql_num_rows($result);
  19. // If result matched $myusername and $mypassword, table row must be 1 row
  20.  
  21. if($count==1) {
  22. // Register $myusername, $mypassword and redirect to file "login_success.php"
  23. session_register("user");
  24. header("location:login_success.php");
  25. }
  26. else {
  27. echo "Wrong Username or Password";
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement