I am not that experienced at html and php but I managed to create a contact form and php script for sending emails to my hotmail account and it has been working fine.
Now i wanted to add Recaptcha to that form and I did it successfully. But now I would like some help on the next topics:
- I want to make recpatcha work with my form
- when recaptcha is Incorrect I want to keep the information fields and Not send the email also Not show the “thank you your message has been sent”.
- only when recaptcha is Correct: send the email, clear the information fields, show “thank you message has been sent”
THIS SCRIPT IS ALL IN ONE PAGE CALL “CONTACTFORM.PHP”
Thank you very much for your answers! If you can give some details for the answer would be great!!!
here I have my codes:
Any help will be very appreciate!
This is my php for sending my email:
[php]<?php
if ($_POST[‘parse_var’] == “form1”){
$emailTitle = 'Email from my website!';
$emailAddress = '[email protected]';
/* Gathering Data Variables */
$emailField = $_POST['email'];
$phoneField = $_POST['phone'];
$nameField = $_POST['name'];
$subjectField = $_POST['subject'];
$messageField = $_POST['message'];
$body = <<<EOD
Email: $emailField
Phone: $phoneField
Name: $nameField
Subject: $subjectField
Message: $messageField
EOD;
$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail("$emailAddress", "$emailTitle", "$body", "$headers");
$sent = "Thank you! Your message has been sent.";
}
?>
Email: | * |
Phone: | |
Name: | * |
Subject: | |
Message: | * |
<?php
if (isset($_POST['send'])) {
require_once('recaptchalib.php');
$privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) { |
|