SHARE
TWEET

Untitled

Ortund Nov 23rd, 2011 53 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["adminid"] = $row["adminid"];
  29.                 $_SESSION["adminname"] = $row["adminname"];
  30.                 $_SESSION["lastlogin"] = $row["lastlogin"];
  31.                
  32.                 $dbh = null;
  33.                 header("Location: /logansarchive/admin/index.php");
  34.         }
  35.         else {
  36.                 $dbh = null;
  37.                 header("Location: /logansarchive/admin/login.php?login_attempt=1");
  38.         }
  39. ?>
  40.  
  41.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top