Ooops sorry - here goes…
This is my original php file:-
<?
/*
reads each form field sent and writes the fieldname and entries to an email.
Expects hidden fields: 'formdest' (address to send the results), 'formsucc' (displayed if sent ok),
'formfail' (displayed if any errors).
Also expects email address field to be called 'email'
Extracts enquiry type to message subject line
*/
$msg1 = ''; $succeeded = ''; $failed = ''; $dest = ''; $sender = ''; $enqs = '';
// sort the POST array
ksort($_POST);
// iterate through the POST data and assign them to the email message or variables
foreach ($_POST as $key => $value) {
if ($key == 'formfail')
$failed = $value;
else if ($key == 'formsucc')
$succeeded = $value;
else if ($key == 'formdest')
$dest = $value;
// add the enquiry types for the subject header
else if (substr($key,0,3) == 'cb_')
if (strlen($enqs))
$enqs .= ', ' . $value;
else
$enqs = $value;
else
$msg1 .= "$key: $value\n";
if ($key == 'email')
$sender = $value;
}
This is the php file for recapatcha:-
<?php
$msg1 = ''; $succeeded = ''; $failed = ''; $dest = ''; $sender = ''; $enqs = '';
// sort the POST array
ksort($_POST);
// iterate through the POST data and assign them to the email message or variables
foreach ($_POST as $key => $value) {
if ($key == 'formfail')
$failed = $value;
else if ($key == 'formsucc')
$succeeded = $value;
else if ($key == 'formdest')
$dest = $value;
// add the enquiry types for the subject header
else if (substr($key,0,3) == 'cb_')
if (strlen($enqs))
$enqs .= ', ' . $value;
else
$enqs = $value;
else
$msg1 .= "$key: $value\n";
if ($key == 'email')
$sender = $value;
}
ini_set("sendmail_from", $dest);
$headers = "From: $dest\r\n";
// send the email
$sent = mail($dest, "Quote Request from Sandydown Website: $enqs", $msg1, $headers, '-f' . $dest);
}if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '
Please go back and check the captcha form.
';
exit;
}
$secretKey = "*********************************";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
header('Location: thankyou.htm');
exit();
}
?>