Advertisement
Guest User

Untitled

a guest
Jul 4th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <?php
  2.  
  3. ob_start();
  4.  
  5. include 'inc/database.php';
  6. include 'php/sanitize.php';
  7.  
  8. $result = mysqli_query($con, "SELECT * FROM `settings` LIMIT 1") or die(mysqli_error($con));
  9. while($row = mysqli_fetch_assoc($result)){
  10.     $website = $row['website'];
  11.     $favicon = $row['favicon'];
  12. }
  13.  
  14. if (!isset($_SESSION)) {
  15.     session_start();
  16. }
  17.  
  18. if (isset($_SESSION['username'])) {
  19.     header('Location: Home');
  20.     exit();
  21. }
  22.  
  23. if(isset($_POST['username']) && isset($_POST['password'])){
  24.  
  25.     $username = sanitizeInput($_POST['username']);
  26.     $password = sanitizeInput($_POST['password']);
  27.     $bcryptFunc = password_hash($password, PASSWORD_BCRYPT);
  28.  
  29.     $result = mysqli_query($con, "SELECT * FROM users WHERE username = '$username'") or die(mysqli_error($con));
  30.     if(mysqli_num_rows($result) < 1){
  31.         $msg = '<div class="alert alert-danger">No user exists</div>';
  32.     }
  33.     while($row = mysqli_fetch_array($result)){
  34.         if(!password_verify($bcryptFunc, $row['password'])) {
  35.             $msg = '<div class="alert alert-danger">The Passwords You Entered Didn\'t Match</div>';
  36.         }
  37.         else
  38.         {
  39.              if($row['status'] == "0")
  40.              {
  41.                 $msg = '<div class="alert alert-danger">You were banned</div>';
  42.              }
  43.              else if($row['status'] == 1)
  44.              {
  45.             $_SESSION['id'] = $row['id'];
  46.             $_SESSION['username'] = $username;
  47.             $_SESSION['email'] = $row['email'];
  48.             $_SESSION['rank'] = $row['rank'];
  49.             header("location: Home");
  50.             }
  51.         }
  52. }
  53.  
  54. }
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement