Ja?
Du har en side der hedder kontakt.php:
- ...
- <?php
- $randTal1 = mt_rand(0, 9);
- $randTal2 = mt_rand(0, 9);
- ?>
- <form action="check.php" method="post">
- <?php echo $randTal1 . " + " . $randTal2 . " = "; ?>
- <input type="text" name="answer" />
- <input type="hidden" value="<?php echo $randTa1l; ?>" name="secret_number1" />
- <input type="hidden" value="<?php echo $randTal2; ?>" name="secret_number2" />
- </form>
Og så check.php
- $randomNr1 = $_POST['secret_number1'];
- $randomNr2 = $_POST['secret_number2'];
- $answer = $_POST['answer'];
- if($randomNr1 + $randomNr2 == $answer) {
- // Kør din kode her
- }