Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login.php
- // Start the session
- session_start();
- // Defines username and password.
- $username = "admin";
- $password = "password";
- // Error message
- $error = "";
- // jestli jsi lognuty
- if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {
- $error = "success";
- header('Location: success.php');
- }
- // jestli je vse zadane
- if (isset($_POST['username']) && isset($_POST['password'])) {
- if ($_POST['username'] == $username && $_POST['password'] == $password) {
- $_SESSION['loggedIn'] = true;
- header('Location: success.php');
- } else {
- $_SESSION['loggedIn'] = false;
- $error = "Špatné jméno nebo heslo :D";
- }
- }
- ?>
- <html>
- <head>
- <title>Login</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body style="text-align: center;">
- <!-- Output error message if any -->
- <?php echo $error; ?>
- <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>>
- <!-- form for login -->
- <div id="frm">
- <form method="post" action="login.php" style="background-color: lime">
- <label for="username">Jmeno:</label><br/>
- <input type="text" name="username" id="username"><br/>
- <label for="password">Heslo:</label><br/>
- <input type="password" name="password" id="password"><br/>
- <input type="submit" value="Prihlasit!!" id="btn" name="btn">
- </form>
- <form action="/index.php" style="background-color: lime">
- <br>
- <input type="submit" value="ZPET" style="text-align:left" id="btn2" name="btn2">
- </form>
- </div>
- <br><br><br><br><br><br><br><br><br><br>
- </body>
- success.php
- <?php
- // Start the session
- ob_start();
- session_start();
- // Check to see if actually logged in. If not, redirect to login page
- if (!isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] == false) {
- header("Location: login.php"); }
- ?>
- logout.php
- <?php
- session_start();
- $_SESSION['loggedIn'] = false;
- header("Location: login.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement