I am a novice with PHP, but I am thinking this should be an easy fix. I think I have most of the code implemented correctly but need to still somehow POST the information from the form through to the clients email.
<?php
require_once('recaptchalib.php');
$privatekey = "(my key is entered here)";
$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
}
?>
My question is, How do I pass the information through above for the “else” option. The original form posted data to a file called contact_p.php. How can I pass my data from the name/company/comment fields through to contact_p.php?
I don’t want it to echo onto the page, I want the information (name/email/company/comment) to pass through to the email address I have set on the contact_p.php page.
What do you mean pass through? you want to get an e-mail?
My echo was simply a demo how to use it. Since you have a form, and you supplied
<input type="text" size="25" name="Name">
Once you hit submit, because you are using the post action in the form, all form elements within that form that has a name attribute (name=“…”) are automagically put into the $_POST array as $_POST[‘whateve the name is’]. (If you used the get method, they are in $_GET). So then you can grab the email address using $_POST[‘emailFrom’]. A lot of people then cast the $_POST[‘emailFrom’] into a nicer variable name using the usual way of casting a variable.
$email = $_POST['emailFrom']
now $email is that value and acts like a regular variable.
<?php
session_start();
require_once('recaptchalib.php');
$privatekey = "(my key is entered here)";
$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
$_SESSION['keeppostalive'] = $_POST;
header('Location: contact_p.php');
}
?>
And then in contact_p.php you would do something like this:
<?php
session_start();
$email = $_SESSION['keeppostalive']['email'];
$name = $_SESSION['keeppostalive']['name'];
$comment = $_SESSION['keeppostalive']['comment'];
// Do what ever comes next;
?>
Add your own security…make sure the POST data is coming from your form, scrub the variable values, and anything else you can think of…