Guest User

Untitled

a guest
May 11th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $noNvabar = '';
  4. if(isset($_SESSION['Username'])){
  5.  
  6. header('Location: dashboard.php');//Redirect to dashboard page
  7.  
  8. }
  9.  
  10. include 'init.php';
  11.  
  12.  
  13.  
  14. // check if user comming from http post request
  15.  
  16. if ($_SERVER['REQUEST_METHOD'] == 'POST'){
  17.  
  18. $username = $_POST['user'];
  19. $password = $_POST['pass'];
  20. $hashedPass = sha1($password);
  21.  
  22. //check if the user exist in the database
  23.  
  24. $stmt = $con->prepare("SELECT Username, Password FROM users WHERE Username = ? AND Password = ?");
  25.  
  26. $stmt->execute(array($username, $hashedPass));
  27. $count = $stmt->rowCount();
  28.  
  29.  
  30. // if count > 0 this mean the database contains record about this username
  31.  
  32. if ($count > 0) {
  33.  
  34. echo 'welcome' . $username;
  35. $_SESSION['Username'] = $username; // Regester Session Nmae
  36. header('Location: dashboard.php');//Redirect to dashboard page
  37. exit();
  38. }
  39. }
  40.  
  41. ?>
  42.  
  43. <form class="login" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
  44. <h4 class="text-center">Admin Login </h4>
  45. <input class="form-control" type="text" name="user" placeholder="Username" autocomplete="off" />
  46.  
  47. <input class="form-control" type="password" name="pass" placeholder="Password" autocomplete="new-Password" />
  48.  
  49. <input class="btn btn-primary btn-block " type="submit" value="login" />
  50.  
  51. </form>
  52.  
  53.  
  54. <?php
  55. include $tbl . 'footer.php';
  56. ?>
Add Comment
Please, Sign In to add comment