使用recaptcha发送错误消息

i wanna show a message in the same page where recaptcha is installed this is my code!

<?php
        require_once('recaptchalib.php');
        $privatekey = "something here";
        $resp = recaptcha_check_answer ($privatekey,
        $_SERVER["REMOTE_ADDR"],
        $_POST["recaptcha_challenge_field"],
        $_POST["recaptcha_response_field"]);
        if (isset($_GET['result']))
        {
        $result = $_GET['result'];
        }

        if ($result == "fail" )
        {
        $content = "The CAPTCHA code was entered incorrectly. Please go back to enter the code and send your form. ";
        }

        else if ($result == "pass" )
        {
        $content = "Thank you. Your form has been submitted.";
        }

?>
<div id="contact-form">
            <form action="recaptcha/contact.php" method="POST" id="contactForm" >
            <div class="form">
                    <label for="name">Your Name: <span class="requireds">(Required)</span><br /></label>
                    <input id="name" name="name" class="text-input" minlength="2" />
           </div>
           <div class="form">
                    <label for="email">Your Email:<span class="requireds">(Required)</span><br /></label>
                    <input id="email" name="email" class=" text-input" />
           </div>
           <div class="form">
                    <label for="phone">Your Phone:<br /></label>
                    <input id="phone" name="phone" type="text"  maxlength="200" class="text-input"  />
           </div>
           <div class="form">
                    <label  for="reason">Contact reason:<br /></label>
                    <select id="reason" name="reason" class="select">
                        <option>Sales question </option>
                        <option>Time/ Delivery</option>
                        <option>My existing Order</option>
                        <option>Technical Question</option>
                        <option>Revision/ Support</option>
                        <option>Other</option>

                    </select>
           </div>
           <div class="form">
                    <label for="message">Message: <span class="requireds">(Required)</span> <br /></label>
                     <textarea id="message" name="message" class="textarea"></textarea>
           </div>

           <div style="margin:10px 0; width:495px; background:#FFF; -moz-border-radius:3px; border-radius:3px;">
                        <?php
                                require_once('recaptcha/recaptchalib.php');
                                $publickey = "6LfPY8YSAAAAAOyYdmV61vtKzIfln9VD0pN2nO-H"; 
                                echo recaptcha_get_html($publickey);
                     ?>
              </div>
               <input type="submit"  value="" class="send"/>

            </form> 
                <?php echo $content; ?>

am getting an error and i dont know what is wrong can somebody help me pls?

UPDATE!!

<?php
        require_once('recaptchalib.php');
        $privatekey = "CENSORED";
        $resp = recaptcha_check_answer ($privatekey,
        $_SERVER["REMOTE_ADDR"],
        $_POST["recaptcha_challenge_field"],
        $_POST["recaptcha_response_field"]);

            $result = (isset($_GET['result']) ? $_GET['result'] : '');

            if ($result == "fail" )
            {
            $content = "The CAPTCHA code was entered incorrectly. Please go back to enter the code and send your form. ";
            }

            else if ($result == "pass" )
            {
            $content = "Thank you. Your form has been submitted.";
            }

$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$reason = $_POST['reason'];

$header = 'From: ' . $email . " 
";

$msg = "Sent from: " . $name . "
";
$msg .= "Email: " . $email . " 
";
$msg .= "Phone: " . $phone . " 
";
$msg .= "Contact reason:" . $reason . " 
";
$msg .= "Message: " . $_POST['message'] . " 
";
$msg .= "Date and time " . date('d/m/Y', time());

$to = '';
$subject = 'Emailmakers contact page';

mail($to, $subject, utf8_decode($msg), $header);

header('location: http://contact-us.php');

?>

THIS IS HOW I HAVE IT NOW AND ISNT WORKING!!!!!!!! WHAT AM I DOING WRONG?

I imagine your error is a notice for an undefined variable $result. You seem to only define $result if $_GET['result'] is set. If it isn't set, you're using it in a comparison and PHP will issue a notice.

Try replacing this:

if (isset($_GET['result']))
{
    $result = $_GET['result'];
}

with this:

$result = (isset($_GET['result']) ? $_GET['result'] : '';

Now you can compare it without an error:

if('' == 'fail')

Also, make sure that your require path is correct:

require_once('recaptcha/recaptchalib.php');

That is a relative path. You might want to include it from the root:

require_once('/recaptcha/recaptchalib.php');

Per the reCAPTCHA documentation, you're supposed to check for validity like this:

  <?php
  require_once('recaptchalib.php');
  $privatekey = "your_private_key";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {
    // Your code here to handle a successful verification
  }

Since you are very new to PHP, this is probably very difficult for you.

No-one can know what is the error you are getting, You are the only person that can debug the problem. So instead of trying to get an answer from you I will give you some techniques which you can use to find and fix the problem yourself.

PHP Error handling

In cases where your script just plain does not work and you might just get a blank page. If this is the case you need to look where PHP sends the error information. There is a lot of information online, I will only sumarise where you should look. There is a PHP configuration file called php.ini and inside there is couple of options to handle errors, namely error_reporting, display_errors, display_startup_errors, log_errors and error_log - If you have access to php.ini you should have a quick look at each of them, If you can see your error it makes things much easier.

Debugging Quick 'n Dirty

Quickest method to debug scripts (for me) is commenting half the code, and using print_r();, var_dump(); and die; to look at important variables (Look up the functions on php.net). Start from the beginning and comment code that you think might be the problem and print_r($variables_that_you_expect_to_be_set); and die; to stop script execution. Play around with block comments to check that parts of your code work correctly individually.

Why this is not a waste of time

You might feel like it should be easy to spot an error by someone else just by looking at your code, and that we are not helping, but believe me, you can't be sure of what the code does until you execute parts of it and confirm the output with the debugging functions outlined above. I speak from experience, having worked on some horrible spaghetti code and debugged it successfully.

Good luck and don't give up.

Chances are, if the page is just white with no output, your require_once() is failing. Check your error logs, and you'll probably see something like:

PHP Fatal error: require_once(): Failed opening required '/path/to/recaptchalib.php'

Also, as ceejayoz suggested, you should follow reCAPTCHA's examples and use their methodology to check for success or failure. The way you are checking your $result, if it's not set to "pass" or "fail", your $content variable will have nothing in it.