Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $userArray = array(
- "username1" => "password1",
- "username2" => "password2",
- "username3" => "password3"
- );
- if (isset($_SESSION['user']))
- {
- $logout=true;
- foreach($userArray as $username)
- {
- if ($username == $_SESSION['user'])
- $logout=false;
- }
- if (isset($_GET['logout'])||$logout=true;)
- {
- session_destroy();
- header("Location: ./");
- }
- //logged in stuff goes here
- }
- else
- {
- if (isset($_POST['username']))
- {
- $username = $_POST['username'];
- $password = $_POST['password'];
- if ($userArray[$username] == $password)
- {
- $_SESSION['user'] = $username;
- header("Location: ./");
- }
- else
- {
- //fail
- }
- }
- ?>
- <form method="post">
- Username: <input name="username" /><br/>
- Password: <input name="password" /><br/>
- <input type="submit" value="Login" />
- </form>
- <?php
- }
- ?>
Add Comment
Please, Sign In to add comment