Guest User

Untitled

a guest
Jun 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2. // initialize session
  3. session_start();
  4.  
  5. include("authenticate.php");
  6.  
  7. // check to see if user is logging out
  8. if(isset($_GET['out'])) {
  9. // destroy session
  10. session_unset();
  11. $_SESSION = array();
  12. unset($_SESSION['user'],$_SESSION['access']);
  13. session_destroy();
  14. }
  15.  
  16. // check to see if login form has been submitted
  17. if(isset($_POST['userLogin'])){
  18. // run information through authenticator
  19. if(authenticate($_POST['userLogin'],$_POST['userPassword']))
  20. {
  21. // authentication passed
  22. header("Location: protected.php");
  23. die();
  24. } else {
  25. // authentication failed
  26. $error = 1;
  27. }
  28. }
  29.  
  30. // output error to user
  31. if(isset($error)) echo "Login failed: Incorrect user name, password, or rights<br />";
  32.  
  33. // output logout success
  34. if(isset($_GET['out'])) echo "Logout successful";
  35. ?>
  36.  
  37. <form action="login.php" method="post">
  38. User: <input type="text" name="userLogin" /><br />
  39. Password: <input type="password" name="userPassword" />
  40. <input type="submit" name="submit" value="Submit" />
  41. </form>
Add Comment
Please, Sign In to add comment