PHP Form with Captcha

Hello everyone,

I’m not good with php programming, so I need your help please. I have a simple form that I would like to add Captcha to. I’ve tried everything to get this form to work with no luck.

The form works perfectly and the captcha images show as they should. I just can’t get the form to process the captcha.

Here’s the form:

<?php 
if(isset($_POST['submit1'])) { 
$to = "me@finnetix.com"; 
$subject = "Finnetix Website Form - Call Back"; 
$name_field = $_POST['name']; 
$phone_field = $_POST['phone']; 
	
foreach($_POST['check'] as $value) { 
$check_msg .= "Urgent: $value\

";
}

$body = "\

From: $name_field
Phone: $phone_field
$check_msg";

echo "Thank you $name_field. We will contact you as soon as possible."; 
mail($to, $subject, $body); 
} else { 
echo "We appreciate that you may not want to fill out a form. To avoid emailing us, you can
request a call back."; 
} 
?>
<br />
<br />
<form method="POST" action="quotes.php">
Name & Surname<br />
<input type="text" name="name" size="20"><br />
<br />
Phone Number<br />
<input type="text" name="phone" size="20"><br />
<br />
Please tick the box if URGENT
<input type="checkbox" name="check[]" value="Yes"><br /> 
<br />

<img src=“captchasecurityimages.php?width=100&height=40&characters=5” alt=“captcha” /><br />
<label for=“security_code”>Security Code</label>
<br /><input id=“security_code” name=“security_code” type=“text” /><br />
<br />
<input type=“submit” value=“Submit” class=“submit1” name=“submit1”>
</form>

The captcha code I need to add is:

if( $_SESSION[‘security_code’] == $_POST[‘security_code’] && !empty($_SESSION[‘security_code’] ) ) {

and

unset($_SESSION[‘security_code’]);
} else {
// Insert your code for showing an error message here
echo ‘Sorry, you have provided an invalid security code.’;
}

but where?? I have tried it so many ways and just can’t figure it out. :injured:
Please help, I’d be forever grateful.