Re: [PHP] Problem with header("Location:" )...
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: >> > >> 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 http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with header("Location:" )...
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: 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 Or is there a better way to do it? Thanks Everyone! Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with header("Location:" )...
Jason Pruim li...@pruimphotography.com On Jul 31, 2011, at 2:50 PM, Dajka Tamas wrote: > Try lowercase 'http'. Anything in error log? Try turning on display_errors. Tried both, upper and lower case http nothing changed... And nothing in the error log... I try a simple echo with a link and that works just fine... Starting to get frustrated with it -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with header("Location:" )...
Try lowercase 'http'. Anything in error log? Try turning on display_errors. Cheers, Tamas -Original Message- From: Jason Pruim [mailto:li...@pruimphotography.com] Sent: Sunday, July 31, 2011 8:40 PM To: Subject: [PHP] Problem with header("Location:" )... 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: 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? Or is there a better way to do it? Thanks Everyone! Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with Header("Location: home.php");
--- CBharadwaj <[EMAIL PROTECTED]> wrote: > In conection.php I have written. > SESSION_ START(); > > on successful login I am registering a session variable. > SESSION_REGISTER("userId"); Do this instead: session_start(); $_SESSION['userid'] = 'myuser'; > Header("Location: home.php"); Use an absolute URL: header('Location: http://example.org/home.php'); > Warning: Cannot modify header information - headers already sent by > (output started at E:\PHPMySql scripts\bugtrack\connection.php:3) > in E:\PHPMySql scripts\bugtrack\index.php on line 117 This call to header() on line 117 of index.php generates an error, because line 3 of connection.php generated output. Calls to header() must come prior to output. You can either rearrange your code or use output buffering: http://www.php.net/ob_start Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with Header("Location: home.php");
On Thursday 12 August 2004 07:48 pm, CBharadwaj wrote: > Hello, > > In conection.php I have written. > SESSION_ START(); ^ Get rid of extra space and it should work Hth, Andre > on successful login I am registering a session variable. > SESSION_REGISTER("userId"); > > on login failure I am redirecting to home page. > Header("Location: home.php"); > > > the following error occuring in above line. > Warning: Cannot modify header information - headers already sent by > (output started at E:\PHPMySql scripts\bugtrack\connection.php:3) > in E:\PHPMySql scripts\bugtrack\index.php on line 117 > > the connection file I have included in every page. > why this error is occuring? > > > Bharadwaj -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with Header("Location: home.php");
> the following error occuring in above line. > Warning: Cannot modify header information - headers already sent by > (output started at E:\PHPMySql scripts\bugtrack\connection.php:3) > in E:\PHPMySql scripts\bugtrack\index.php on line 117 Have you got any space before you output anything to the browser? I've found that often I've saved a file with a newline at the end by accident - meaning that PHP thinks I'm ready to start sending output and therefore any functions that modify the headers won't work because they've already been sent. Check connection.php around line 3 to see if there is anything sending output before you call session_* or Header(). BTW, you shouldn't use relative URIs in Location: headers, try using: header('Location: http://www.mydomain.com/path/to/home.php'); instead (this won't fix anything, but it's the correct way to do it according to the HTTP/1.1 standard). Hope this helps, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php