probably missing '}'
close to the ending: die("The captcha you entered was incorrect")
I also added one exit() after header:location
it is good practice to do so,
to really stop script from running AFTER the REDIRECT has taken place!!!!
header("Location: $redirect");
exit();
this is how I think it is supposed to be
<?php
session_start();
if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) )
{
unset($_SESSION['security_code']);
function spamcheck($email)
{
$email=filter_var($email, FILTER_SANITIZE_EMAIL);
if(filter_var($email, FILTER_VALIDATE_EMAIL))
return TRUE;
else
return FALSE;
}
$email=$_REQUEST['email'];
if (isset($_REQUEST['email']))
{
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "Please enter a correct email address. Press the Back button to go back.";
}
else
{
$message = "";//Message starts empty
while (list($key, $value) = each($_REQUEST))
{ //Populate variables from GET and POST
${$key} = $value;//this assigns all the variables in GET and POST to their names.
//filter out a couple of ones that shouldn't be included in the email
if (strtolower($key) != "submit" && strtolower($key) != "redirect" && strtolower($key) != "phpsessid")
$message .= $key . ": " . stripslashes($value) . "\n\r";//add the rest to the $message variable
} //end Populate Variables
if(mail($recipient, $subject, $message, 'From: ' . $name . ' <' . $email . '>'))//try sending the mail...
{
header("Location: $redirect");//Forward them to the redirect location.
exit();
}
else
{ //if the mail didn't send (returned false) report an error.
?>Sorry, there was an error. The form was not submitted. Please click <a href="contactus.php">here</a> to resubmit.
<?php
}
}
}
}
else
{
die("The captcha you entered was incorrect");
}
?>