Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. //start session
  3. session_start();
  4.  
  5. include_once('user.php');
  6.  
  7. $user = new User();
  8.  
  9. if(isset($_POST['login'])){
  10. $attempts=0;
  11.  
  12.  
  13.  
  14. $username = $user->escape_string($_POST['username']);
  15. $password = $user->escape_string($_POST['password']);
  16.  
  17. $auth = $user->check_login($username, $password);//authentication
  18.  
  19.  
  20.  
  21. if(!$auth){
  22.  
  23.  
  24.  
  25. $_SESSION['message'] = 'Invalid username or password '.$attempts.'';
  26. header('location:index.php');
  27. }
  28. else{
  29.  
  30.  
  31.  
  32. $_SESSION['user'] = $auth;
  33. header('location:home.php');
  34.  
  35. }
  36. }
  37. else{
  38. $_SESSION['message'] = 'You need to login first';//this part is to check your $postlogin=name of submit button
  39. header('location:index.php');
  40. }
  41.  
  42.  
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement