On Jul 31, 2011, at 6:23 PM, Tamara Temple wrote: > > On Jul 31, 2011, at 1:40 PM, Jason Pruim wrote: > >> So I'm attempting to redirect back to the main site of a page after a successful insert into a database... Here's my code: >> <?PHP >> >> 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 { >> >> $name = mysql_real_escape_string($_POST['txtName']); >> $comment = mysql_real_escape_string($_POST['areaComment']); >> $phonelink = mysql_real_escape_string($_POST['phonelink']); >> $SQL = "INSERT INTO comments (name, comment, phonelink) VALUES ('$name', '$comment', '$phonelink')"; >> >> mysql_query($SQL) or die("Unable to insert at this time. Sorry for the inconvience"); >> //echo "Insert successful!"; >> header("Location: HTTP://jason.pruimphotography.com/dev/clients/flewid/Phone/"); >> >> >> // Your code here to handle a successful verification >> } >> >> >> ?> >> >> >> The insert happens, BUT it won't redirect back to the site.... There isn't any reason I should be able to do a header() redirect at that point is there? > > Since the echo is commented out, there shouldn't be any output if that is sum total of the code executing on the http request. If this file is called from some other script, you might check to see if any output is sent from there. If display_errors is on, you should be getting something like "Unable to send headers after output" or some such (I can't offhand think of the actual error message). > > You can keep the "error successful" message for verification if you write it directly to the error log, via: > > error_log("Insert successful".PHP_EOL); > > Sometimes, it's also nice to insert markers to let you know where the log is emanating from: > > error_log(__FILE__.'@'.__LINE__.': '."Insert successful".PHP_EOL); > > Sometimes, a vexing sort of error is a blank line at the top or bottom of a file, outside the <?..?> Just before I got your e-mail, I found there were 3 spaces at the very top of the file in front of my <?PHP.... I was fit to be tied as they say in the south... But it is up and working properly now! Thank you all for your help with this! :) Jason Pruim lists@xxxxxxxxxxxxxxxxxxxx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php