Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $email = trim($_POST['email']);
- $password = $_POST['password'];
- $error = '';
- if(empty($email) || empty($password)){
- $error = '<p class="error">Invaid email or password.</p>';
- }else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
- $error = '<p class="error">Invaid email or password.</p>';
- }else{
- $stmt = $link->prepare("SELECT * FROM users WHERE email = ?");
- $stmt->bind_param('s', $email);
- $stmt->execute();
- /* fetch value */
- $res = $stmt->get_result();
- if($user = $res->fetch_object()){
- if(password_verify($password , $user->password )){
- //login is true
- $_SESSION['user'] = array(
- 'uid' => $user->id,
- 'email' => $user->email
- );
- $_SESSION['login'] = true;
- if($user_type == "1"){ //check usertype
- header("Location:dashboard.php");
- }else{
- header("Location:dashboard_usr.php");
- }
- }else{
- $error = '<p style="color: #ea2b1f">Ooops! Invaid email or password.</p>';
- }
- }
- }
Add Comment
Please, Sign In to add comment