Advertisement
Ortund

Untitled

Nov 23rd, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $username = $_REQUEST["txt_username"];
  3.     $password = $_REQUEST["txt_password"];
  4.    
  5.     $host = "127.0.0.1";
  6.     $user = "root";
  7.     $pass = "12157114";
  8.    
  9.     try {
  10.         $dbh = new PDO("mysql:host=$host;dbname=logansarchive", $user, $pass);
  11.         $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12.     }
  13.     catch(PDOException $e) {
  14.         echo $e->getMessage();
  15.     }
  16.    
  17.     $hashed_pass = substr(sha1($password), 0, 10);
  18.    
  19.     $sql = "select count(*) as count, adminid, adminname, lastlogin from admin where adminname = :name and adminpass = :pass";
  20.     $result = $dbh->prepare($sql);
  21.    
  22.     $result->bindParam(":name", $username);
  23.     $result->bindParam(":pass", $hashed_pass);
  24.    
  25.     $row = $dbh->query($sql)
  26.     if ($row["count"] == 1) {      
  27.         $_SESSION["adminid"] = $row["adminid"];
  28.         $_SESSION["adminname"] = $row["adminname"];
  29.         $_SESSION["lastlogin"] = $row["lastlogin"];
  30.        
  31.         $dbh = null;
  32.         header("Location: /logansarchive/admin/index.php");
  33.     }
  34.     else {
  35.         $dbh = null;
  36.         header("Location: /logansarchive/admin/login.php?login_attempt=1");
  37.     }
  38. ?>
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement