Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- session_start();
- $userinfo = array('user1'=>'password1');
- if(isset($_GET['logout'])) {
- $_SESSION['username'] = '';
- header('Location: ' . $_SERVER['PHP_SELF']);
- }
- if(isset($_POST['username'])) {
- if($userinfo[$_POST['username']] == $_POST['password']) {
- $_SESSION['username'] = $_POST['username'];
- }else {
- echo "Wrong password";
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Login</title>
- </head>
- <body>
- <?php if($_SESSION['username']): ?>
- <p>You are logged in as <?=$_SESSION['username']?></p>
- <p><a href="?logout=1">Logout</a></p>
- <?php else: ?>
- <form name="login" action="log.php" method="post">
- Username: <input type="text" name="username" value="" /><br />
- Password: <input type="password" name="password" value="" /><br />
- <input type="submit" name="submit" value="Submit" />
- </form>
- <?php endif; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement