Jump to content

reCaptcha conflict and error...


Jim R

Recommended Posts

I've tried two separate captcha options, Securimage and reCaptcha, which is the one I currently have on my page.  I got the same error with each code:

 

Warning: Cannot modify header information - headers already sent by (output started at /home/jwrbloom/public_html/metroindybasketball.com/form/dbenter.php:20) in /home/jwrbloom/public_html/metroindybasketball.com/form/dbenter.php on line 101

 

 

It's a conflict with the code that moves my User to the 'next step'.

 

Here is the code:  (scroll down toward the bottom, just before the email fields)

 

<?php
  require_once('/home/jwrbloom/public_html/metroindybasketball.com/recaptcha/recaptchalib.php');
  $privatekey = "6LetxbwSAAAAAMP2q1q5F5S_tiEcu1sH1_dM3DTl ";
  $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
  }
  ?>



<?php
/*
connect to database
*/
if(!$con = mysql_connect("localhost","######","######")) {
   die("Could not connect to database: ".mysql_error());
}
mysql_select_db("######_wpMIB", $con);

$nameFirst = $_POST['nameFirst'];
$nameLast = $_POST['nameLast'];
$email = $_POST['email'];
$addressHome = $_POST['addressHome'];
$cityHome = $_POST['cityHome'];
$stateHome = $_POST['stateHome'];
$zipHome = $_POST['zipHome'];
$phoneHome = $_POST['phoneHome'];
$phoneMobile = $_POST['phoneMobile'];
$school = $_POST['school'];
$grade = $_POST['grade'];
$coachSchool = $_POST['coachSchool'];
$feet = $_POST['feet'];
$inches = $_POST['inches'];

/*
search for existing row
*/
$sql = "SELECT id FROM fallLeague10 WHERE nameFirst='".mysql_real_escape_string($nameFirst)."' AND nameLast='".mysql_real_escape_string($nameLast)."' AND school='".mysql_real_escape_string($school)."'";
if(!$result = mysql_query($sql)) {
   die(mysql_error()."<br />Query: ".$sql);   
}
if(mysql_num_rows($result)) {
  $row = mysql_fetch_assoc($result);
  /*
  update existing row
  */
  $sql = "UPDATE fallLeague10 SET 
                  confirm='y', 
                  email='".mysql_real_escape_string($email)."', 
                  addressHome='".mysql_real_escape_string($addressHome)."', 
			  cityHome='".mysql_real_escape_string($cityHome)."',
                  stateHome='".mysql_real_escape_string($stateHome)."', 
                  zipHome='".mysql_real_escape_string($zipHome)."', 
                  phoneHome='".mysql_real_escape_string($phoneHome)."', 
                  phoneMobile='".mysql_real_escape_string($phoneMobile)."', 
                  coachSchool='".mysql_real_escape_string($coachSchool)."', 
                  feet='".mysql_real_escape_string($feet)."', 
                  inches='".mysql_real_escape_string($inches)."' 
                  WHERE id='".$row['id']."'";
   if(!$result = mysql_query($sql)) {
      die(mysql_error()."<br />Query: ".$sql);   
   }
}
else {
  /*
  insert new row
  */   
  $sql = "INSERT INTO fallLeague10 SET 
              confirm='y', 
		  nameFirst='".mysql_real_escape_string($nameFirst)."',
              nameLast='".mysql_real_escape_string($nameLast)."',
              email='".mysql_real_escape_string($email)."', 
              addressHome='".mysql_real_escape_string($addressHome)."', 
		  cityHome='".mysql_real_escape_string($cityHome)."',
		  stateHome='".mysql_real_escape_string($stateHome)."', 
              zipHome='".mysql_real_escape_string($zipHome)."', 
              phoneHome='".mysql_real_escape_string($phoneHome)."', 
              phoneMobile='".mysql_real_escape_string($phoneMobile)."', 
		  school='".mysql_real_escape_string($school)."', 
		  grade='".mysql_real_escape_string($grade)."',			  
              coachSchool='".mysql_real_escape_string($coachSchool)."', 
              feet='".mysql_real_escape_string($feet)."', 
              inches='".mysql_real_escape_string($inches)."'";
   if(!$result = mysql_query($sql)) {
      die(mysql_error()."<br />Query: ".$sql);   
   }
}

/*
redirect user  HERE IS WHERE I AM HAVING MY ERROR
*/
header("Location:/fall-league/payment");
//exit();
?>


<?php
// The message
$message =  $_POST['nameFirst'] . " " . $_POST['nameLast'] ." has entered the fall league.\n";
$message .=  $_POST['feet'] . "'" . $_POST['inches'] ."\", " . $_POST['grade'] . "; " .  $_POST['school'] ."\n";
$message .=  $_POST['email'];


// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

$headers = 'From: ' . $_POST['nameFirst'] . " " . $_POST['nameLast'] . " " . $_POST['email'];

// Send
mail('basketball@metroindybasketball.com', '2010 Fall League Registration', $message, $headers);



?>

Link to comment
Share on other sites

It's a conflict with the code that moves my User to the 'next step'.

 

No it's not. It's a header error because you are outputting some characters to the browser before you try to send a header -

 

output started at /home/jwrbloom/public_html/metroindybasketball.com/form/dbenter.php:20 (line 20)

 

Look at your code up to line 20 to find what output you are sending and eliminate that output.

 

It looks to me that you have a closing php tag ?> at about line 16, about three new-lines, and an opening php tag at about line 20. Those three new-lines that are outside of the php tags are being sent to the browser.

 

Why do you even have a closing php tag and an opening php tag there? It's all php code, don't even put a closing/opening php tag there in it.

Link to comment
Share on other sites

Just read your error messages. They were created to help you find the error.

 

Some programmer went to a lot of trouble to make sure that error message told you both where the header was at that was not working and where the output was at that was preventing it from working.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

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