Captcha code in form

They have: 112 posts

Joined: Aug 2001

I wonder if anyone can help me. I'm trying to insert some captcha code (from white-hat-web-design.co.uk) in an existing form but I'm not very good with php. I've got the other files in the program worked out but this last one I'm lost. Two bits of code are below .... how does the captcha code go in the process file code?

Captcha Code

<?php

   session_start
();
   if((
$_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
     
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
     
unset($_SESSION['security_code']);
   } else {
     
// Insert your code for showing an error message here
  
}
?>

Process File Code

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Firstname');
pt_register('POST','Lastname');
pt_register('POST','Email');
pt_register('POST','Phonenumber');
pt_register('POST','Yourenquiry');
$Yourenquiry=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Yourenquiry);if($Firstname=="" || $Lastname=="" || $Email=="" || $Yourenquiry=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!
eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if(
$errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="First name: ".$Firstname."
Last name: "
.$Lastname."
Email: "
.$Email."
Phone number: "
.$Phonenumber."
Your enquiry: "
.$Yourenquiry."
"
;
$message = stripslashes($message);
mail(info@sampledomain.com,"Form Submitted at your website",$message,"From: phpFormGenerator");

header("Refresh: 0;url=http://www.sampledomain.com/thankyou.html");
?>

<?php

}
?>

Thanks all Laughing out loud