Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function login($uname,$upass)
- {
- try
- {
- $stmt = $this->conn->prepare("SELECT * FROM tbl_users WHERE userName=:name_id");
- $stmt->execute(array(":name_id"=>$uname));
- $userRow=$stmt->fetch(PDO::FETCH_ASSOC);
- if($stmt->rowCount() == 1)
- {
- if($userRow['userStatus']=="Y")
- {
- if($userRow['userPass']==md5($upass))
- {
- $_SESSION['userSession'] = $userRow['userID'];
- return true;
- }
- else
- {
- header("Location: index.php?error");
- exit;
- }
- }
- else
- {
- header("Location: index.php?inactive");
- exit;
- }
- }
- else
- {
- header("Location: index.php?error");
- exit;
- }
- }
- catch(PDOException $ex)
- {
- echo $ex->getMessage();
- }
- }
- public function is_logged_in()
- {
- if(isset($_SESSION['userSession']))
- {
- return true;
- }
- }
- public function redirect($url)
- {
- header("Location: $url");
- }
- public function logout()
- {
- session_destroy();
- $_SESSION['userSession'] = false;
- }
- // LOGIN //
- $user_login = new USER();
- if($user_login->is_logged_in()!="")
- {
- $user_login->redirect('home.php');
- }
- if(isset($_POST['btn-login']))
- {
- $email = trim($_POST['txtemail']);
- $upass = trim($_POST['txtupass']);
- if($user_login->login($email,$upass))
- {
- $user_login->redirect('home.php');
- }
- }
Add Comment
Please, Sign In to add comment