Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. include('database.php');
  6.  
  7. //Form-data
  8. $user = $_POST['user'];
  9. $pass = $_POST['pass'];
  10.  
  11. //Protect from MySQL-injection
  12. $user = stripslashes($user);
  13. $pass = stripslashes($pass);
  14. $user = mysql_real_escape_string($user);
  15. $pass = mysql_real_escape_string($pass);
  16.  
  17. $sql = "SELECT * FROM $members_table WHERE username='$user' and password='$pass'";
  18.  
  19. $result = mysql_query($sql);
  20.  
  21. $count = mysql_num_rows($result);
  22.  
  23. if($count == 1){
  24.  
  25.     $_SESSION['user'] = $user;
  26.     $_SESSION['pass'] = $pass;
  27.     header("location:login_success.php");
  28.    
  29. }
  30.  
  31. else{
  32.    
  33.     header("location:index.php");
  34.    
  35. }
  36.    
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement