Hi Ray, could you possibly take a look at this updated code and tell me what I'm doing wrong? The page loads but when I submit the form the page truncates just before this code block:
<?php // Check if form was submitted:
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])) {
// Build POST request:
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_secret = 'SECRET_KEY';
$recaptcha_response = $_POST['recaptcha_response'];
// Make and decode POST request:
$recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
$recaptcha = json_decode($recaptcha);
// Take action based on the score returned:
if ($recaptcha->score >= 0.5)
{
//WA Universal Email
$Email = new WA_Email("index_2");
$Email->Redirect = "".(htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)) ."?sent=true#success";
$Email->From = "".((isset($_POST["name"]))?$_POST["name"]:"") ." <mwilson@linksdesign.co.uk>";
$Email->addTo("MY_EMAIL");
$Email->BodyFile = "webassist/email/contact.php";
if (function_exists("rel2abs") && $Email->Redirect) $Email->Redirect = $Email->Redirect?rel2abs($Email->Redirect,dirname(__FILE__)):"";
for ($emailGroup=0; $emailGroup<sizeof($Email->To); $emailGroup++) {
$Email->Subject = "Contact from Website";
$Email->send($emailGroup);
}
$Email->close();
} else {
echo("Spam test failed");
}
} ?>
If I replace the email code block with echo("Spam test passed"); it submits and shows the message so I know I've done something wrong in the email code!