Advertisement
Guest User

Untitled

a guest
Jul 6th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4.     $username = $_POST['username'];
  5.     $password = $_POST['password'];
  6.     $expiry = new Datetime('+1 year');
  7.     setcookie('username', $username, $expiry->getTimestamp());
  8.     setcookie('password', $password, $expiry->getTimestamp());
  9.     echo $_COOKIE['username'].", ".$_COOKIE['password'];
  10. }
  11. ?>
  12. <form action="#" method="post">
  13.     <label for="username">Username: </label><input type="text" name="username"><br />
  14.     <label for="password">Password: </label><input type="text" name="password"><br />
  15.     <input type="submit" name="submit" value="Submit">
  16. </form>
  17. <div class="parent">
  18.     <?php
  19.         if(!empty($_COOKIE)) {
  20.             echo $_COOKIE['username'];
  21.         }
  22.         else {
  23.             echo '';
  24.         }
  25.     ?>
  26. </div>
  27. <style>
  28.     .parent {
  29.         background-color: red;
  30.         width: 500px;
  31.         height: 500px;
  32.         text-align: center;
  33.         line-height: 500px;
  34.     }
  35. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement