Advertisement
Guest User

Untitled

a guest
Dec 20th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2. $username = array('user1','user2');
  3. $password = array ('pass1','pass2');
  4.  
  5.  
  6. if (isset($_POST['username']) && isset($_POST['password'])) {
  7. // get key of posted username from $user array, will be false if not available
  8. if(($key = array_search($_POST['username'], $username)) !== NULL){
  9. // now check the password
  10. if($_POST['password'] == $password[$key]){
  11. $_SESSION['loggedIn'] = true;
  12. header('Location: success.php');
  13. }
  14. }
  15. }
  16. ?>
  17. <html>
  18. <head>
  19. <title>Login Page</title>
  20. </head>
  21.  
  22. <body>
  23. <!-- Output error message if any -->
  24. <?php echo $error; ?>
  25.  
  26. <!-- form for login -->
  27. <form method="post" action="login.php">
  28. <label for="username">Username:</label><br/>
  29. <input type="text" name="username" id="username"><br/>
  30. <label for="password">Password:</label><br/>
  31. <input type="password" name="password" id="password"><br/>
  32. <input type="submit" value="Log In!">
  33. </form>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement