Advertisement
vencinachev

Login

Oct 29th, 2020
2,382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. // ==== FILE 0
  2. <!DOCTYPE>
  3. <html>
  4.     <head>
  5.         <title>Login</title>
  6.         <meta charset="utf8">
  7.     </head>
  8.     <body bgcolor="#00DD5D">
  9.         <h1> Влез в системата</h1>
  10.         <form method="post" action="loginreq.php">
  11.             Потребителско име: <input type="text" name="uname"> </br></br>
  12.             Парола: <input type="password" name="pass"> </br></br>
  13.             <input type="submit" value="=== ВЛЕЗ ===">
  14.         </form>
  15.     </body>
  16. </html>
  17.  
  18.  
  19. //============= FILE 1 =============
  20. <?php
  21.     session_start();
  22.    
  23.     if ($_POST['uname'] == "uktc" && $_POST['pass'] == '1234'){
  24.         $_SESSION['login'] = "ok";
  25.         header("Location: secret1.php");
  26.     } else {
  27.         echo "Invalid username or password";
  28.     }
  29. ?>
  30.  
  31. //============= FILE 2 =============
  32.  
  33. <?php
  34.   session_start();
  35.   if (!isset($_SESSION['login'])){
  36.       header("Location: login.php");
  37.   }
  38. ?>
  39.  
  40. <!DOCTYPE>
  41. <html>
  42.     <head>
  43.         <title>Page 1</title>
  44.         <meta charset="utf8">
  45.     </head>
  46.     <body bgcolor="#FFDD5D">
  47.         <h1> Това е много секретен сайт. Страница 1</h1>
  48.         <a href="secret2.php"> Page 2 </a>
  49.     </body>
  50. </html>
  51.  
  52. // ===== FILE 3
  53.  
  54. <?php
  55.   session_start();
  56.   if (!isset($_SESSION['login'])){
  57.       header("Location: login.php");
  58.   }
  59. ?>
  60. <!DOCTYPE>
  61. <html>
  62.     <head>
  63.         <title>Page 2</title>
  64.         <meta charset="utf8">
  65.     </head>
  66.     <body bgcolor="#FFDDFF">
  67.         <h1> Това е много секретен сайт. Страница 2</h1>
  68.         <a href="secret1.php"> Page 1 </a>
  69.     </body>
  70. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement