Advertisement
Guest User

Untitled

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