In the form that you want to submit ad the following code
Ok, in the submit page ad the following code
This is just an example, but it can be more modified, but this is a simple way of having a capcha system on your website.
I will be posting another code too soon which uses images instead of text.
Code:
<?php $min_number = 1; $max_number = 10; $random_number1 = mt_rand($min_number, $max_number); $random_number2 = mt_rand($min_number, $max_number); echo "<span style=\"background-color:#000000; color:#FFFFFF; border:#000099 thin solid\"><b><big>$random_number1 + $random_number2</big></b></span><br />"; ?> <input name="result" type="text" size="3" /><br /> <input name="n1" type="hidden" value="<?=$random_number1; ?>" /> <input name="n2" type="hidden" value="<?=$random_number2; ?>" />
Code:
<?php $result = $_POST["result"]; $n1 = $_POST["n1"]; $n2 = $_POST["n2"]; $total = $n1 + $n2; if ($result == $total) { // Paste content here, which will show if the code is entered correct. I left the javascript in just to make it easier for you to understand for first use. echo "<script>alert('Correct answer');</script>"; } else { // If the code is wrong it will outpt this... echo "<script>alert('Wrong answer entered, please retry');</script>"; } ?>
I will be posting another code too soon which uses images instead of text.
Comment