Guest User

Untitled

a guest
May 25th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2.  
  3. include "db.php";
  4.  
  5. session_start();
  6.  
  7. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  8.  
  9. $enteredUsername = strtolower($_POST['inputUsername']);
  10.  
  11. $enteredPassword = $_POST['inputPassword'];
  12.  
  13. $hashedPassword = hash('tiger192,4', $enteredPassword);
  14.  
  15. if (("" == trim($_POST['inputUsername'])) or ("" == trim($_POST['inputPassword']))) {
  16.  
  17. echo '<div class="alert alert-danger text-center" style="margin:20px;" role="alert">No data has been entered, please check and try again.</div>';
  18.  
  19. }
  20.  
  21. else {
  22.  
  23. $sql1 = "SELECT `username` FROM `login` WHERE `username`='$enteredUsername' AND `password`='$hashedPassword'";
  24.  
  25. if ($query_run = mysqli_query($conn,$sql1)) {
  26.  
  27. $query_num_rows = mysqli_num_rows($query_run);
  28.  
  29. if ($query_num_rows == 0) {
  30.  
  31. echo '<div class="alert alert-danger text-center" style="margin:20px;" role="alert">Username or Password was invalid, please check and try again.</div>';
  32.  
  33. }
  34.  
  35. else if ($query_num_rows == 1) {
  36.  
  37. echo '<div class="alert alert-success text-center" style="margin:20px;" role="alert">Login successful.</div>';
  38.  
  39. $_SESSION['loggedin'] = 'yes';
  40.  
  41. $_SESSION["username"] = $enteredUsername;
  42.  
  43. //$locationLogin = 'Location: ;
  44.  
  45. //header($locationLogin);
  46.  
  47. }
  48.  
  49. }
  50.  
  51. }
  52.  
  53. }
  54.  
  55. ?>
Add Comment
Please, Sign In to add comment