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 . " \r\n";
$msg = "Sent from: " . $name . "\r\n";
$msg .= "Email: " . $email . " \r\n";
$msg .= "Phone: " . $phone . " \r\n";
$msg .= "Contact reason:" . $reason . " \r\n";
$msg .= "Message: " . $_POST['message'] . " \r\n";
$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?
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$contentvariable will have nothing in it.