Advertisement
rawyon

Untitled

Mar 14th, 2011
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2. /**
  3.  *admin.php
  4.  *
  5.  * Inloggning
  6.  *
  7.  */
  8.  
  9. // header
  10. require "headermall.php";
  11. // <div id content
  12. echo "<div id='content'>\n";
  13.  
  14. session_start();
  15.  
  16. //anslut.php
  17. require "anslut.php";
  18.  
  19. // inloggningskontroll
  20. require("messages.php"); //Copywriting
  21. if ( empty($_POST) ) {
  22.         //  Visa formulär för första gången
  23.         $error_message = "";
  24.         include "loginmall.php";
  25.         }
  26.              
  27. else {
  28.    //kontrollera uppgifter
  29.    $stmt = $dbh->prepare(
  30.    "SELECT
  31.      username,
  32.      password,
  33.      email,
  34.      realname,
  35.      title
  36.   FROM
  37.      admin
  38.   WHERE
  39.      username = :username AND password = SHA1(:password)");
  40.      
  41.    $stmt->bindParam('username', $_POST ['username']);
  42.    $stmt->bindParam('password', $_POST ['password']);    
  43.    $stmt->execute();
  44.  
  45.       $fail = !$stmt->fetch ();
  46.       if ($fail)  {
  47.  //         $login_message = $loginmsg ['fail'];
  48.           include "loginmall.php";          // Visa formulär
  49.           if ( isset ($_SESSION['login'] ) ) {
  50.                 unset($_SESSION[$_LOGIN]);
  51.                 }
  52.       echo "Du har skrivit in fel lösenord/användarnamn, försök igen!";
  53.       }
  54.    else {
  55.         // Inloggnig lyckad!
  56.         session_regenerate_id();
  57.         $_SESSION['login'] = $_POST['username'];
  58.         header("Location: admin_page_1.php");
  59.         exit;
  60.         }
  61. }
  62. // slut på content
  63. echo "</div>\n";
  64.  
  65. require "footermall.php";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement