Advertisement
Guest User

Untitled

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