How to integrate the recaptcha .php file to the existing .php file on the site..

Good morning everyone ;D

I have successfully added the recaptcha to the contact form and it is working fine.

The only problem I am having is adding the original code and that tells the contact form to send the information input by the visitor to an email address.

I have the original php file which was working and sends the information by email successfully. I have the new php file which ensures that the recaptcha is completed successfully before being allowed to submit the information but I need to merge the two together so that both actions take place when the recaptcha is successful and then the information is sent to the specified email address.

It looks so simple that I simply need to add my information from my original file to the top of the php file for recaptcha but I just can’t get it to work!

I hope this makes sense and I haven’t rambled on too much :o

Sarah
xxxx


formmail-new.png

Couldn’t you not post the script between php tags? I would love to help, but I can’t see the code and I’m on an 27" iMac with 5K Display. :-\ In addition my eyesight isn’t what it used to be.

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(); } ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service