Advertisement
Ortund

Untitled

Nov 24th, 2011
102
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.     $stmt = $result->execute();
  26.     $row = $stmt->fetch();
  27.     if ($row["count"] == 1) {
  28.         session_start();
  29.         $_SESSION["adminid"] = $row["adminid"];
  30.         $_SESSION["adminname"] = $row["adminname"];
  31.         $_SESSION["lastlogin"] = $row["lastlogin"];
  32.        
  33.         $dbh = null;
  34.         header("Location: /logansarchive/admin/index.php");
  35.     }
  36.     else {
  37.         $dbh = null;
  38.         header("Location: /logansarchive/admin/login.php?login_attempt=1");
  39.     }
  40. ?>
  41.  
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement