Advertisement
leonsuke

Login with PDO

May 24th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.    
  4.     require_once 'dbconn.php';
  5.    
  6.     $username = $_POST['username'];
  7.     $password = md5($_POST["password"]);
  8.    
  9.     if (isset($_POST["submit"]))
  10.     {
  11.         $stmt  = $con->prepare("SELECT * FROM user WHERE username = :username AND password = :password");
  12.         $stmt->execute(array(":username"=>$username, ":password"=>$password));
  13.         $obj   = $stmt->fetchObject();
  14.         $total = $stmt->rowCount();
  15.        
  16.        
  17.         if ($total > 0 && $password = $obj->password)
  18.         {
  19.            $_SESSION["username"] = $obj->username;
  20.            $_SESSION["jabatan"] = $obj->jabatan;
  21.            
  22.            
  23.         }
  24.     }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement