Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $control = 0;
- session_start();
- if (!isset($_SESSION["username"]) && !isset($_GET["page"])) {
- $control = 0;
- }
- if ($_GET["page"] == "log") {
- $user = $_POST["user"];
- $password = $_POST["password"];
- if ($user == "Example" && $password == "12345") {
- $_SESSION["username"] = $user;
- $control = 1;
- } else {
- $control = 2;
- }
- }
- ?>
- <html>
- <head>
- <title>Login</title>
- <?php
- if ($control == 1) {
- ?>
- <meta http-equiv="refresh" content="3; URL=seite2.php">
- <?php
- }
- ?>
- </head>
- <body>
- <?php
- if ($control == 0) {
- ?>
- Please enter your username and you password<br/>
- <form method="post" action="index.php?page=log">
- Username: <input type="text" name="user" value="OK"/><br/>
- Password: <input type="password" name="password" /><br/>
- <button type="submit">Login</button>
- </form>
- <?php
- }
- if ($control == 1) {
- ?>
- Login successful, you will be redirected
- <?php
- }
- if ($control == 2) {
- ?>
- Wrong username or password, <a href="index.php">try again</a>.
- <?php
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment