I have a Custom Form and wanted to secure the Form submission with Human Check, by asking visitors to enter the given Random Number to validate.
Below is the function to generate a Random number:
function random_number() {
$rand1 = rand(10, 100);
$rand2 = rand(10, 100);
$randnum = $rand1 * $rand2;
return $randnum;
}
Below is the Validation Form the Human Check:
<label for="humanCheck">
<?php echo random_number(); ?>
</label>
<input id="humanCheck" type="number" name="message_human" placeholder="Enter above number">
Below is the Validation Code to check whether visitor entered the given random number:
$randomnumbercheck = echo random_number();
if (!$human == 0) {
if ($human != $randomnumbercheck) {
response("error", $not_human); //not human!
} else {
/// form submission
}
Problem is random numbers generated by the random_number()
function in both Validation form & validation code are different and it is always a false validation.
Aucun commentaire:
Enregistrer un commentaire