Advertisement
MY_H4CK3R

login

Jul 16th, 2017
62
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. error_reporting(0);
  3. session_start();
  4.  
  5. $userinfo = array('user1'=>'password1');
  6.  
  7. if(isset($_GET['logout'])) {
  8. $_SESSION['username'] = '';
  9. header('Location: ' . $_SERVER['PHP_SELF']);
  10. }
  11.  
  12. if(isset($_POST['username'])) {
  13. if($userinfo[$_POST['username']] == $_POST['password']) {
  14. $_SESSION['username'] = $_POST['username'];
  15. }else {
  16. echo "Wrong password";
  17. }
  18. }
  19. ?>
  20. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  21. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  22. <html xmlns="http://www.w3.org/1999/xhtml">
  23. <head>
  24. <title>Login</title>
  25. </head>
  26. <body>
  27. <?php if($_SESSION['username']): ?>
  28. <p>You are logged in as <?=$_SESSION['username']?></p>
  29. <p><a href="?logout=1">Logout</a></p>
  30. <?php else: ?>
  31. <form name="login" action="log.php" method="post">
  32. Username: <input type="text" name="username" value="" /><br />
  33. Password: <input type="password" name="password" value="" /><br />
  34. <input type="submit" name="submit" value="Submit" />
  35. </form>
  36. <?php endif; ?>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement