Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //index.php
- <?php
- //Check for the existence of the cookie
- if(!empty($_COOKIE['passed_index'])){
- header("Location:q1.php");
- }
- if(array_key_exists("dad", $_POST)){
- $dad = $_POST["dad"];
- $correct_answer = "Fail";
- if($dad == $correct_answer){
- setcookie('passed_index', '1' ,time()+60*60*24); //This line sets the cookie for 1 year
- header("Location: q1.php");
- }else{
- $wrong="<div class='error'>Wrong answer</div>";
- }
- }
- ?>
- <form action="index.php" method="post">
- <label>Enter your father's name:</label>
- <input autofocus required autocomplete="off" type="text" name="dad" placeholder="Bill">
- <input type="submit" value="Press me when you think you are right" />
- <?php
- echo $wrong;
- ?>
- </form>
- //q1.php
- <div>
- 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.
- </div>
- <form action="q2.php" method="post">
- <label>Enter your mother's name:</label>
- <input autofocus required autocomplete="off" type="text" name="mom" placeholder="Billette"><br>
- <input type="submit" value="Poke me. I dare you.">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement