Jump to content

Recaptcha PHP Error


Recommended Posts

Hi All,


Very new to PHP so I wonder if you can help.


I have set up a form with Recaptcha on it. The form posts the information on the front page (which works). The only problem is that I want the code to send the user back to the home page.


  $privatekey = "6LfxZN8SAAAAAIxozrSnTxTgrAljrQlM0R7k8yEQ";
  $resp = recaptcha_check_answer ($privatekey,

  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 . ")");
  } elseif {
    // Your code here to handle a successful verification
	$connect = mysql_connect("localhost","hautopsy_root","Kings!123") or die ("couldnt connect");
   	$db = mysql_select_db("hautopsy_netconfess") or die ("database error");

   	$name = strip_tags($_POST['name']);
   	$confession = ($_POST['confession']);
   	$datetime = date ("Y:m:d:H:m:s");

   	$query = mysql_query("insert into nc (name, confession, datetime) values('$_POST[name]', '$_POST[confession]', '$datetime')") or die ("failed to insert");
	header('Location: http://www.example.com/');

header("Location: index.php");


I am using header("Location: index.php"); but it just seems to be staying on the same page.



Link to comment
Share on other sites

Perhaps theres spaced lines in your require('recaptcha'); ? I've had that happen before it is very tedious. If it is making that last insert when you run the code I'd definately check that.

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called.

Edited by remenissions
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.