Hi Everybody,
I have a simple form that mixes HTML and PHP. I thought I could get fancy and add a simple security level before the form action.
I have a snippet that prepares for a random number between 1 and 99, and call that random number $entry
<?php
$firstnumb = rand(1,9);
$secondnumb = rand(1,99);
$entry = $firstnumb + $secondnumb;
?>
A visitor will see a display box that asks them to add the two numbers ...
<?php
print "<SPAN style='color: #0000FF'><B>$firstnumb + $secondnumb</B></SPAN>";
?>
and enter the answer in a text box
<input type="text" class="form-control" placeholder="Enter the answere here" id="entry1" name="entry1" required >
So now I just have to compare the value of $entry to the value of entry1, and do one of two things. That's where I crash and burn.
If the values compare, I just need to break and move on
If the values do not compare, then I want to:
Replace the value of entry1 to "0"
Alert the visitor that he needs to correct their answer.
Return focus to the input box and do it again. Perhaps allow a limit of 3 attempts.
I don't know how to do any of this and hope someone will help me.
Many Thanks,
Paul