Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.04 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4.    $num1 = Rand(0,10);
  5.    $num2 = Rand(0,10);
  6.  
  7.    if(is_int($_POST['userInput']) == 1) {
  8.        
  9.        if($num1 * $num2 == $_POST['userInput']) {
  10.            header("Location: correct.html");
  11.            
  12.            exit();
  13.        } else {
  14.            echo "WRONG!";
  15.        }
  16.    }
  17.  
  18.    //Produce two variables with random integer between 1 and 10.
  19.  
  20.  
  21. ?>
  22.  
  23. <!doctype html>
  24. <html>
  25.    
  26.     <head>
  27.         <meta charset="utf-8">
  28.         <title>Simple Math Quiz</title>
  29.     </head>
  30.     <body>
  31.  
  32.         <h1><?php echo "What is " . $num1 . " times " . $num2 . "?"?></h1>
  33.        
  34.         <?php
  35.            
  36.        ?>
  37.        
  38.         <form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
  39.             <input type="text" name="userInput"/>
  40.             <br/>
  41.             <br/>
  42.             <button type="submit" name="submit" value="send">Submit</button>
  43.             <input type="hidden" name="answer" value="<?php echo $answer; ?>" />
  44.         </form>
  45.        
  46.    
  47.     </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement