Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("inc/config.php");
- session_start();
- // Clean Credentials
- $cid = htmlspecialchars($_POST[cid]);
- $password = mysql_real_escape_string($_POST[password]);
- // Complete Credentials
- if(empty($cid) || empty($password))
- {
- header("Location: /lib/login.php?e=1");
- exit();
- }
- // Grab User Information
- $stmt = $db->prepare("SELECT * FROM users WHERE cid = :cid");
- $stmt->execute(array(':cid' => $cid));
- $user = $stmt->fetch(PDO::FETCH_ASSOC);
- // Account Exists
- public function AccountExists($db, $user, $stmt)
- {
- $count = $stmt->rowCount();
- if($count < 1)
- {
- header("Location: /lib/login.php?e=2");
- exit();
- }
- }
- AccountExists($db, $user, $stmt);
- // Account Inactive
- public function AccountInactive($db, $user)
- {
- if($user[status] == 1)
- {
- header("Location: /lib/login.php?e=3");
- exit();
- }
- }
- AccountInactive($db, $user);
- // Account Suspended
- public function AccountSuspended($db, $user)
- {
- if($user[status] == 3)
- {
- header("Location: /lib/login.php?e=4");
- exit();
- }
- }
- AccountSuspended($db, $user);
- // Password Verify
- public function CheckPassword($db, $user)
- {
- $hash = $user[password];
- if(password_verify($password, $hash) === true)
- {
- return true;
- } else {
- return false;
- }
- }
- public function Login($db, $user)
- {
- if(CheckPassword($db, $user) === true)
- {
- $_SESSION['main'] = $user[id];
- header("Location: /?p=dashboard");
- }
- }
- Login($db, $user);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement