Advertisement
vladislavkopilov

3-4

Nov 4th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. //admin - 1234
  3. if( isset($_POST["login"]) && isset($_POST["pass"]) &&
  4.     !empty($_POST["login"]) && !empty($_POST["pass"]) &&
  5.     !isset($_GET["exit"])
  6.     ){
  7.     if($_POST["login"]=="admin" && $_POST["pass"]==1234){
  8.         setcookie('exit', 'yes', time() + (60*60*8));
  9.         header('Refresh: 1; url=http://phpchallenge.dev04/3-4.php');
  10.     }else{
  11.         echo "Пользователь не найден";
  12.     }
  13. }
  14. if($_GET["singout"]=="yes"){
  15.     setcookie('exit', '', 1);
  16.     header('Refresh: 1; url=http://phpchallenge.dev04/3-4.php');
  17. }
  18. ?>
  19. <!doctype html>
  20. <html>
  21.  <head>
  22.  <title></title>
  23.  <meta charset="utf-8">
  24.  </head>
  25.  <body>
  26.     <?php if($_COOKIE["exit"]){ ?>
  27.         <p>Добро пожаловать!!!</p>
  28.         <a href="<?php echo $_SERVER['PHP_SELF'];?>?singout=yes">Выйти</a>
  29.     <?php }else{ ?>
  30.     <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
  31.         <input type="text" name="login" placeholder="Login" />
  32.         <input type="text" name="pass" placeholder="Password"/>
  33.         <input type="submit" value="sing in" />
  34.         <input type="reset" />
  35.     </form>
  36.     <?php } ?>
  37.  <body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement