Jump to content

Recaptcha with php guestbook


valoukh

Recommended Posts

Hi all,

 

I've installed "Recaptcha" on my php guestbook to stop spam and up until today I thought it was working fine. However, I've realised that it only seems to work in IE, not Mozilla (the main two browsers I test with). Here's the page:

 

http://www.denbygrace.com/HTML/guestbook.php

 

I understand that code can be interpreted differently in the different browsers but I wasn't aware that this was the case with basic php (IF and INSERTS etc). Can anyone help?

 

Here's the code:

 

<?
$sql="INSERT INTO guestbook (subject, date, comment, name)
VALUES
('$_POST[subject]','$_POST[date]','$_POST[comment]','$_POST[name]')";

require_once('recaptchalib.php');
$privatekey = "(removed)";
$error = null;

$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if ($resp->is_valid) {
echo "<p class='title'>Comment added, thank you! Click <a href='../HTML/guestbook.php'>here</a> to return to the <b>Guestbook</b> page.</p>";
$result = mysql_query($sql);

} else {
  die ("<p class='title'>The reCAPTCHA wasn't entered correctly. Please return to the <a href='guestbook.php'>Guestbook</a> page and try again.</p>");
}
?>

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/109761-recaptcha-with-php-guestbook/
Share on other sites

It is likely that the form is incorrect and is not submitting the data in one browser. When a form operates differently in different browsers, it is usually because the HTML on the page is invalid and one browser ignores the errors and allows the form to work, while the errors stop the other browser from seeing the form the right way.

 

There are a number of HTML validation errors at the URL you posted - http://validator.w3.org/check?uri=http%3A%2F%2Fwww.denbygrace.com%2FHTML%2Fguestbook.php&charset=%28detect+automatically%29&doctype=Inline&group=0

 

Fix those and see what you get.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.