Advertisement
Guest User

Login

a guest
May 17th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?php
  2. if ($Config["Logopen"] != 0)    {
  3.     if (isset($_POST['sendLogin'])) {
  4.         $username = $_POST['username'];
  5.         $password = $_POST['password'];
  6.        
  7.         $encryptPassword = sha1($password);
  8.        
  9.         if (!empty($username) && (!empty($password)))   {
  10.             $fetchData = "SELECT * FROM useraccounts WHERE username = '$username' AND password = '$encryptPassword'";
  11.             if ($stmt = $conn->prepare($fetchData)) {
  12.                 $stmt->execute();
  13.                 $stmt->store_result();
  14.                 if ($stmt->num_rows > 0)    {
  15.                     $stmt->close();
  16.                     $getMoreInfo = "SELECT username, active FROM useraccounts WHERE username = '$username'";
  17.                     if ($stmt = $conn->prepare($getMoreInfo))   {
  18.                         $stmt->execute();
  19.                         $stmt->bind_result($username, $active);
  20.                             while ($stmt->fetch())  {
  21.                                 if ($active > 0)    {
  22.                                     $_SESSION["Login"] = $username;
  23.                                     echo '<div class="alert alert-success"><i class="fa fa-spin fa-spinner"></i> Succesfully logged in, redirecting...</div>';
  24.                                     echo '<script>
  25.                                         $(window).load(function () {
  26.                                             window.setTimeout(function () {
  27.                                                 window.location.href = "managetickets.php";
  28.                                             }, 2000)
  29.                                         });
  30.                                     </script>';
  31.                             } else {
  32.                                     echo '<div class="alert alert-warning"><i class="fa fa-user-times"></i> This account has been set to disabled.</div>';
  33.                                 }
  34.                             }
  35.                         $stmt->close();
  36.                     }
  37.                 } else {
  38.                     $stmt->close();
  39.                     echo 'Wrong';
  40.                 }
  41.             }
  42.         } else {
  43.             echo '<div class="alert alert-danger"><i class="fa fa-times"></i> Please fill in a username and password.</div>';
  44.         }
  45.         $conn->close();
  46.     }
  47. } else {
  48.     echo '<div class="alert alert-warning"><i class="fa fa-times"></i> Sorry, but logging in has been disabled.</div>';
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement