Guest User

Loginform

a guest
Jan 16th, 2016
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2. $control = 0;
  3. session_start();
  4. if (!isset($_SESSION["username"]) && !isset($_GET["page"])) {
  5.     $control = 0;
  6. }
  7. if ($_GET["page"] == "log") {
  8.     $user = $_POST["user"];
  9.     $password = $_POST["password"];
  10.     if ($user == "Example" && $password == "12345") {
  11.         $_SESSION["username"] = $user;
  12.         $control = 1;
  13.     } else {
  14.         $control = 2;
  15.     }
  16. }
  17. ?>
  18. <html>
  19. <head>
  20.     <title>Login</title>
  21.     <?php
  22.     if ($control == 1) {
  23.     ?>
  24.         <meta http-equiv="refresh" content="3; URL=seite2.php">
  25.     <?php
  26.     }
  27.     ?>
  28. </head>
  29. <body>
  30. <?php
  31. if ($control == 0) {
  32. ?>
  33.     Please enter your username and you password<br/>
  34.     <form method="post" action="index.php?page=log">
  35.         Username: <input type="text" name="user" value="OK"/><br/>
  36.         Password: <input type="password" name="password" /><br/>
  37.         <button type="submit">Login</button>
  38.     </form>
  39. <?php
  40. }
  41. if ($control == 1) {
  42. ?>
  43.     Login successful, you will be redirected
  44. <?php
  45. }
  46. if ($control == 2) {
  47. ?>
  48.     Wrong username or password, <a href="index.php">try again</a>.
  49. <?php
  50. }
  51. ?>
  52. </body>
  53. </html>
Add Comment
Please, Sign In to add comment