Advertisement
Hadi1989

Untitled

Dec 26th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     require_once 'conn.php';
  4.    
  5.     if(ISSET($_POST['login'])){
  6.         $username = $_POST['username'];
  7.         $password = $_POST['password'];
  8.        
  9.         $query = "SELECT COUNT(*) as count FROM `member` WHERE `username` = :username AND `password` = :password";
  10.         $stmt = $conn->prepare($query);
  11.         $stmt->bindParam(':username', $username);
  12.         $stmt->bindParam(':password', $password);
  13.         $stmt->execute();
  14.         $row = $stmt->fetch();
  15.        
  16.         $count = $row['count'];
  17.        
  18.         if($count > 0){
  19.             header('location:home.php');
  20.         }else{
  21.             $_SESSION['error'] = "Invalid username or password";
  22.             header('location:login.php');
  23.         }
  24.     }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement