Advertisement
DominikHeiseOfficial

ghjz

Jul 4th, 2018
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 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. }elseif($row['status'] == "0"){
  37. $msg = '<div class="alert alert-danger">You were banned</div>';
  38. }else{
  39. $_SESSION['id'] = $row['id'];
  40. $_SESSION['username'] = $username;
  41. $_SESSION['email'] = $row['email'];
  42. $_SESSION['rank'] = $row['rank'];
  43. header("location: Home");
  44. }
  45. }
  46.  
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement