Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = $_REQUEST["txt_username"];
- $password = $_REQUEST["txt_password"];
- $host = "127.0.0.1";
- $user = "root";
- $pass = "12157114";
- try {
- $dbh = new PDO("mysql:host=$host;dbname=logansarchive", $user, $pass);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e) {
- echo $e->getMessage();
- }
- $hashed_pass = substr(sha1($password), 0, 10);
- $sql = "select count(*) as count, adminid, adminname, lastlogin from admin where adminname = :name and adminpass = :pass";
- $result = $dbh->prepare($sql);
- $result->bindParam(":name", $username);
- $result->bindParam(":pass", $hashed_pass);
- $stmt = $result->execute();
- $row = $stmt->fetch();
- if ($row["count"] == 1) {
- session_start();
- $_SESSION["adminid"] = $row["adminid"];
- $_SESSION["adminname"] = $row["adminname"];
- $_SESSION["lastlogin"] = $row["lastlogin"];
- $dbh = null;
- header("Location: /logansarchive/admin/index.php");
- }
- else {
- $dbh = null;
- header("Location: /logansarchive/admin/login.php?login_attempt=1");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement