Advertisement
Guest User

Untitled

a guest
Aug 7th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <?php
  2. session_start();
  3. echo isset($_SESSION['login']);
  4. if(isset($_SESSION['login'])) {
  5. header('LOCATION:index.php'); die();
  6. }
  7. ?>
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta http-equiv='content-type' content='text/html;charset=utf-8' />
  12. <title>Login</title>
  13. <meta charset="utf-8">
  14. <meta name="viewport" content="width=device-width, initial-scale=1">
  15. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  16. </head>
  17. <body>
  18. <div class="container">
  19. <h3 class="text-center">Login</h3>
  20. <?php
  21. if(isset($_POST['submit'])){
  22. $username = $_POST['username']; $password = $_POST['password'];
  23. if($username === 'admin' && $password === 'password'){
  24. $_SESSION['login'] = true; header('LOCATION:admin.php'); die();
  25. } {
  26. echo "<div class='alert alert-danger'>Username and Password do not match.</div>";
  27. }
  28.  
  29. }
  30. ?>
  31. <form action="" method="post">
  32. <div class="form-group">
  33. <label for="username">Username:</label>
  34. <input type="text" class="form-control" id="username" name="username" required>
  35. </div>
  36. <div class="form-group">
  37. <label for="pwd">Password:</label>
  38. <input type="password" class="form-control" id="pwd" name="password" required>
  39. </div>
  40. <button type="submit" name="submit" class="btn btn-default">Login</button>
  41. </form>
  42. </div>
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement