Guest User

Untitled

a guest
Mar 5th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. login.php
  2. <?php
  3. session_start();
  4. if($_POST) {
  5.     $username = trim($_POST['name']);
  6.     $password = trim($_POST['pass']);
  7.     if($username === "admin" && $password === "admin") {
  8.         $_SESSION["authenticated"] = "true";
  9.         header("Location: admin.php");
  10.     }
  11.     else {
  12.         header("Location: login.php?error=1");
  13.     }
  14. }
  15.  
  16. ?>
  17.  
  18. <?php if(isset($_GET['error'])): ?>
  19. <p class="error">Zlé prihlasovacie meno alebo heslo!</p>
  20. <?php endif; ?>
  21. <form method="post" action="">
  22.     <p>
  23.         <label for="name">Prihlasovacie meno:</label>
  24.         <input type="text" name="name" id="name" value="<?php if(isset($_POST['name'])) $_POST['name'] ?>" />
  25.     </p>
  26.     <p>
  27.         <label for="pass">Heslo:</label>
  28.         <input type="password" name="pass" id="pass" />
  29.     </p>
  30.     <input type="submit" value="prihlásiť" />
  31. </form>
  32.  
  33. admin.php
Add Comment
Please, Sign In to add comment