Guest User

Untitled

a guest
May 4th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. index.php:
  2.  
  3. <?php
  4.     session_start();
  5.     if(!isset($_SESSION['isLogged']))
  6.     {
  7.             header_remove();
  8.             header('Location: login.php');
  9.             die;
  10.     }
  11.     echo "Te-ai logat cu succes! </br>";
  12.     echo "<a href=\"logout.php\">Logout</a>";
  13. ?>
  14.  
  15. login.php:
  16.  
  17.  
  18. <?php
  19.     session_start();
  20.     include 'config.php';
  21.     if(isset($_SESSION['isLogged']))
  22.     {
  23.             header_remove();
  24.             header('Location: index.php');
  25.             die;
  26.     }
  27.     if(isset($_POST["Login"]))
  28.     {
  29.         $Username = $_POST["Username"];
  30.         $Password = $_POST["Password"];
  31.         $stmt = $pdo->query("SELECT * FROM admin");
  32.         $adminArray = $stmt->fetch();
  33.         if($adminArray['Utilizator'] == $Username && $adminArray['Parola'] == $Password)
  34.         {
  35.             $_SESSION['isLogged']= $Username;
  36.             echo '<script type="text/javascript">windows.open("index.php","_self");</script>';
  37.         }
  38.     }
  39. ?>
  40.  
  41. <html>
  42.     <body>
  43.         <form action="" method="post">
  44.             <center>
  45.                 <label><b>Utilizator: </b></label>
  46.                 <input type="text" name="Username">
  47.                            
  48.                 <label><b>Password: </b></label>
  49.                 <input type="password" name="Password">
  50.                            
  51.                 <input type="submit" value="LOGIN" name="Login">
  52.             </center>
  53.         </form>
  54.     </body>
  55. </html>
  56.  
  57. logout.php:
  58.  
  59. <?php
  60.     session_start();
  61.     if(isset($_SESSION['isLogged']))
  62.         session_destroy();
  63.     else
  64.         {  
  65.             header_remove();
  66.             header('Location: login.php');
  67.             die;
  68.         }
  69. ?>
Add Comment
Please, Sign In to add comment