Captcha: How to embed the CAPTCHA
Step 1:
Embedding the CAPTCHA into the contact form or guestbook:
Source code for displaying the image:
<img src="https://all-inkl.com/captcha/captcha.php" border="0" title="Security code">
Source code for the input field:
<input type="text" name="security code" size="5">
Embedding into the email script :
Now it has to be checked whether the entered code in the form is identical with the code on the CAPTCHA image. This happens in the script which is called up by the form.
Here is the related code for the verfication:
<?
session_start();
if(isset($_SESSION['captcha_spam']) AND $_POST["security code"] == $_SESSION['captcha_spam'])
{
unset($_SESSION['captcha_spam']);
Now follows the code for the evaluation and emailing of the data entered in the form. This is only an example and the related code from your script should be shown instead:
$mail_empfaenger=$_POST['recipient'];
$mail_absender=$_POST['email address'];
$betreff=$_POST['subject'];
$text="My name is " . $_POST['first name'] . " " . $_POST['last name'];
mail($mail_empfaenger, $betreff, $text,"from:$mail_absender");
echo "The email has been successfully sent";
Termination of the script and error message in case of entering an incorrect security code:
}else
{
die ("Security code is incorrect!");
}
?>
Search in support and FAQ