Advertisement
Guest User

Untitled

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