Advertisement
Guest User

All Experts Answer

a guest
Feb 22nd, 2013
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1. //index.php
  2. <?php
  3.     //Check for the existence of the cookie
  4.     if(!empty($_COOKIE['passed_index'])){
  5.       header("Location:q1.php");
  6.     }
  7.  
  8.     if(array_key_exists("dad", $_POST)){
  9.         $dad = $_POST["dad"];
  10.         $correct_answer = "Fail";
  11.         if($dad == $correct_answer){
  12.             setcookie('passed_index', '1' ,time()+60*60*24); //This line sets the cookie for 1 year
  13.             header("Location: q1.php");
  14.         }else{
  15.             $wrong="<div class='error'>Wrong answer</div>";
  16.         }
  17.     }
  18. ?>
  19. <form action="index.php" method="post">
  20.     <label>Enter your father's name:</label>
  21.     <input autofocus required autocomplete="off" type="text" name="dad" placeholder="Bill">
  22.     <input type="submit" value="Press me when you think you are right" />
  23.     <?php
  24.       echo $wrong;
  25.     ?>
  26. </form>
  27.  
  28. //q1.php
  29.     <div>
  30.         Hah! Just a lucky guess! I could probably do that if I was blindfolded and my hands were tied behind my back. Let's see if you can do another one.
  31.     </div>
  32.     <form action="q2.php" method="post">
  33.         <label>Enter your mother's name:</label>
  34.         <input autofocus required autocomplete="off" type="text" name="mom" placeholder="Billette"><br>
  35.         <input type="submit" value="Poke me. I dare you.">
  36.     </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement