Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = array('user1','user2');
- $password = array ('pass1','pass2');
- if (isset($_POST['username']) && isset($_POST['password'])) {
- echo "<pre>";
- print_r($_POST);
- // get key of posted username from $user array, will be false if not available
- if(($key = array_search($_POST['username'], $username)) !== NULL){
- echo "user test is passed";
- // now check the password
- if($_POST['password'] == $password[$key]){
- echo "password test is passed";
- exit;
- $_SESSION['loggedIn'] = true;
- header('Location: success.php');
- }
- }
- }
- ?>
- <html>
- <head>
- <title>Login Page</title>
- </head>
- <body>
- <!-- Output error message if any -->
- <?php echo $error; ?>
- <!-- form for login -->
- <form method="post" action="login.php">
- <label for="username">Username:</label><br/>
- <input type="text" name="username" id="username"><br/>
- <label for="password">Password:</label><br/>
- <input type="password" name="password" id="password"><br/>
- <input type="submit" value="Log In!">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement