Ok, now my form.php with the reCaptcha is being sent to the validate.php and if valid goes on to form_processor.php where it sends my email the results.
The problem is the form comes to my email empty. How do I get the form variables (name, address and phone) to pass over to the validate.php and sent along to the form_processor.php so that it comes into my email?
Below is my code:
THE FORM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../form.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColFixCtr">
<div id="container">
<div id="mainContent">
<h1> form test</h1>
<div id="form">
<form id="form1" name="form1" method="post" action="verify.php">
name
<label>
<input type="text" name="name" id="name" />
</label>
<br />
address
<label>
<input type="text" name="address" id="address" />
</label>
<br />
phone
<label>
<input type="text" name="phone" id="phone" />
</label>
<br />
<?php
require_once('recaptchalib.php');
$publickey = "xxxxxxxxxxxxxxxx";
echo recaptcha_get_html($publickey);
?> <br />
<input type="submit" name="button" id="button" value="Submit" />
</form>
</div>
<p> </p>
<h2> </h2>
<!-- end #mainContent --></div>
<!-- end #container --></div>
</body>
</html>
VERIFY.PHP
?php
require_once('recaptchalib.php');
$privatekey = "xxxxxxxxxxxxxxx";
$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 {
header("Location: form_processor.php");
}
?>
FORM_PROCESSOR.PHP
<?php
// Subject of email sent to you.
$subject = 'New Form Response';
// Your email address. This is where the form information will be sent [email]info@mywebsite.com[/email].
$emailadd = 'cj@mywebsite.com';
// Where to redirect after form is processed.
$url = 'http://MYWEBSITE.COM/Thank_you.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>