Guest User

Untitled

a guest
Jun 28th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Validating Login...</title>
  6. </head>
  7. <body>
  8. <?php
  9.     session_start();
  10.     // Connecting to the database
  11.     include 'mysql.php';
  12.     mysql_connect("$host", "$username", "$password")or die("There was an error when attempting to establish a connection with the database.");
  13.     mysql_select_db("$database")or die("There was an error selecting the news system database.");
  14.    
  15.     // Sanitize input to prevent injections
  16.     $username = mysql_real_escape_string($username);
  17.     // Encrypt the password so real input isn't stored in the cookie
  18.     $password = sha1($_POST['password']);
  19.    
  20.     // Perform the SQL queries
  21.     $db = new mysqli($host, $username, $password, $database);
  22.     $login = $db -> stmt_init();
  23.    
  24.    
  25.     $login->bind_param('ss', $username, $password);
  26.  
  27.     if($login->prepare("SELECT * FROM $login_table WHERE `username` = ?, `password` = ?")) {
  28.             $_SESSION["valid_user"] = $_POST["username"];
  29.             $_SESSION["vzalid_time"] = time();
  30.             $_SESSION["valid_pw"] = $password;
  31.             Header("Location: admin.php");
  32.         } else {
  33.             die("Invalid login.");
  34.             }
  35. ?>
  36.  
  37.  
  38. </body>
  39. </html>
Add Comment
Please, Sign In to add comment