Recaptcha. Need some php for integrating recaptcha to form. This may be simple

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:

  1. I want to make recpatcha work with my form
  2. 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”.
  3. 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."; 

}
?>

      <td align="right"><label for="reset"></label></td>
      <td align="left"><label for="send"></label>
        <input type="hidden" name="parse_var" id="parse_var" value="form1" />

        <input name="send" type="submit" id="send" onclick="MM_validateForm('email','','RisEmail','name','','R','message','','R');return document.MM_returnValue" value="Send Email" /> <label for="reset"></label>
        <input type="reset" name="reset" id="reset" value="Reset form" /></td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td align="left" class="content">(*) Are Required fields</td>
    </tr>
    <tr>
      <td colspan="2" align="center"><?php print "$sent"; ?> 



     </td>
      </tr>
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) {
echo “Please try again”;
} else {
echo “Correct”;
}
}
?>

<?php require_once('recaptchalib.php'); $publickey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // you got this from the signup page echo recaptcha_get_html($publickey); ?>
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service