Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2. require_once("inc/config.php");
  3. session_start();
  4.  
  5. // Clean Credentials
  6. $cid = htmlspecialchars($_POST[cid]);
  7. $password = mysql_real_escape_string($_POST[password]);
  8.  
  9. // Complete Credentials
  10. if(empty($cid) || empty($password))
  11. {
  12.     header("Location: /lib/login.php?e=1");
  13.     exit();
  14. }
  15.  
  16. // Grab User Information
  17. $stmt = $db->prepare("SELECT * FROM users WHERE cid = :cid");
  18. $stmt->execute(array(':cid' => $cid));
  19. $user = $stmt->fetch(PDO::FETCH_ASSOC);
  20.  
  21. // Account Exists
  22. public function AccountExists($db, $user, $stmt)
  23. {
  24.     $count = $stmt->rowCount();
  25.     if($count < 1)
  26.     {
  27.         header("Location: /lib/login.php?e=2");
  28.         exit();
  29.     }
  30. }
  31.  
  32. AccountExists($db, $user, $stmt);
  33.  
  34. // Account Inactive
  35. public function AccountInactive($db, $user)
  36. {
  37.     if($user[status] == 1)
  38.     {
  39.         header("Location: /lib/login.php?e=3");
  40.         exit();
  41.     }
  42. }
  43.  
  44. AccountInactive($db, $user);
  45.  
  46. // Account Suspended
  47. public function AccountSuspended($db, $user)
  48. {
  49.     if($user[status] == 3)
  50.     {
  51.         header("Location: /lib/login.php?e=4");
  52.         exit();
  53.     }
  54. }
  55.  
  56. AccountSuspended($db, $user);
  57.  
  58. // Password Verify
  59. public function CheckPassword($db, $user)
  60. {
  61.     $hash = $user[password];
  62.     if(password_verify($password, $hash) === true)
  63.     {
  64.         return true;
  65.     } else {
  66.         return false;
  67.     }
  68. }
  69.  
  70. public function Login($db, $user)
  71. {
  72.     if(CheckPassword($db, $user) === true)
  73.     {
  74.         $_SESSION['main'] = $user[id];
  75.         header("Location: /?p=dashboard");
  76.     }
  77. }
  78.  
  79. Login($db, $user);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement