I have the reCAPTCHA between my form tags, yet the form fields never
make it through. I have setup a print_r to dump the contents of the
$_POST array, and it does, but no captcha fields exist in it. Here's
the site in question:
http://www.watcheslikenew.com/sendtofriend.php?id=1273 .. after
hitting submit, you must view the source and review line 150. You
will see the variables being passed through $_POST. When I set my
configuration to display PHP errors, it tells me that
"recaptcha_challenge_field" and "recaptcha_response_field" are not
valid indexes for $_POST. Any ideas?
Here's a snippit of my code:
<? include ("inc/constants.php") ?>
<? include ("inc/header.php") ?>
<? require_once('recaptchalib.php'); // for captcha ?>
<? $publickey = "..."; // for captcha ?>
<p class="heading">SEND THIS PAGE TO A FRIEND</p>
<script type="text/javascript">
var RecaptchaOptions = { theme : 'white' };
</script>
<?
if ($process == 1) {
print "<!-- <pre>";
print_r($_POST);
print $recaptcha_challenge_field;
print "</pre> -->";
$error = "";
$privatekey = "...";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error = $resp->error;
$id = $_POST['PID'];
} else {
$subject = "$name wants you to see this item at WatchesLikeNew.com";
$mailcontent = "Hello,<br>\nI found this watch at WatchesLikeNew.com
and thought you might find it of interest.<br>\n<br>\n";
$mailcontent = $mailcontent."Link: <a href=\"http://
www.watcheslikenew.com/detail.php?id=".$PID."\">
http://www.watcheslikenew.com/detail.php?id=".$PID."</a>";
$toaddress = $emailto;
$fromaddress = $email;
mail($toaddress, $subject, $mailcontent, "From: $name <$fromaddress>
\nReply-To: $name <$fromaddress>\nContent-type: text/html");
echo "<p>Thank you. An email has been sent to your friend.<br><br><a
href=\"detail.php?id=$PID\">Click here to return to that watch</a>.</
p>";
$sent = true;
}
}
if (!isset($sent)) {
$sql="SELECT * FROM T1Brands,T2Watches WHERE T1BrandsID = T2BrandsFK
AND T2WatchesID = $id";
$result=mysql_query($sql,$db);
$num = mysql_num_rows($result);
if ($num > 0) {
$row = mysql_fetch_array($result);
?>
<table border="0" cellspacing="0" cellpadding="3" align="center">
<form method="post" action="sendtofriend.php">
<input type="hidden" name="process" value="1">
<input type="hidden" name="PID" value="<?=$id?>">
<tr>
<td class="blue"><b>Inventory #:</b> </td>
<td><?=$row["T2Sku"]?></td>
<td rowspan="5" align="right" valign="top">
<table border="0" cellspacing="0" cellpadding="1"
bgcolor="#6666CC">
<tr>
<td><a href="detail.php?id=<?=$id?>"><img src="/images/p/<?=$row
["T2Image1"]?>" width="82" height="122" border="0"></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="blue"><b>Brand:</b></td>
<td><?=$row["T1BrandsName"]?></td>
</tr>
<tr>
<td class="blue"><b>Model:</b></td>
<td><?=$row["T2Model"]?></td>
</tr>
<tr>
<td class="blue"><b>Status:</b></td>
<td><?=$row["T2Status"]?></td>
</tr>
<tr>
<td class="blue"><b>Price:</b></td>
<td>$<?=$row["T2Price"]?></td>
</tr>
<tr>
<td><br><br></td>
</tr>
<tr>
<td><b>Friend's Email:</b></td>
<td colspan="2"><input type="text" name="emailto" size="30"
class="input200" value="<? echo (isset($_POST['emailto'])?$_POST
['emailto']:""); ?>"></td>
</tr>
<tr>
<td><b>Your Name:</b></td>
<td colspan="2"><input type="text" name="name" size="30"
class="input200" value="<? echo (isset($_POST['name'])?$_POST
['name']:""); ?>"></td>
</tr>
<tr>
<td><b>Your Email:</b></td>
<td colspan="2"><input type="text" name="email" size="30"
class="input200" value="<? echo (isset($_POST['email'])?$_POST
['email']:""); ?>"></td>
</tr>
<tr>
<td colspan="2" align="center"><? echo recaptcha_get_html
($publickey, $error); ?></td>
</tr>
<tr>
<td colspan="3" align="right"><input type="submit" name="submit"
value="Submit" class="button"></td>
</tr>
</form>
</table>
<? } else { echo "Sorry, that product no longer exists."; }
} ?>
<? include ("inc/footer.php") ?>