SteveMann Posted February 4, 2010 Share Posted February 4, 2010 I hope that this is a simple "DOH!" solution. I have a page with a form on it, and the form action is to call my database insertion in a separate php file. This particular php file does not interact with the user it just adds the data to a mysql database. Is there a method where I can send the user's browser to another page when the database update is complete - but without a button? I just want to start the PHP execution then go to a "thank-you" page. Thanks Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 4, 2010 Share Posted February 4, 2010 header( 'Location: newpage.php' ); exit(); Quote Link to comment Share on other sites More sharing options...
SteveMann Posted February 4, 2010 Author Share Posted February 4, 2010 Thanks, but I get the following error: "Warning: Cannot modify header information - headers already sent by..." I didn't think that I could put a header() after the php had already started. Good idea, though.. Quote Link to comment Share on other sites More sharing options...
$Three3 Posted February 4, 2010 Share Posted February 4, 2010 You can use the ob_start() function and the ob_flush() function: http://php.net/manual/en/function.ob-start.php http://www.php.net/manual/en/function.ob-flush.php Then you will be able to send the code: header('Location: thank_you.php') exit(); Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 4, 2010 Share Posted February 4, 2010 http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment Share on other sites More sharing options...
trq Posted February 4, 2010 Share Posted February 4, 2010 Thanks, but I get the following error: "Warning: Cannot modify header information - headers already sent by..." I didn't think that I could put a header() after the php had already started. Good idea, though.. Your processing script shouldn't generate any output, this way you can call header when its done. Quote Link to comment Share on other sites More sharing options...
SteveMann Posted February 4, 2010 Author Share Posted February 4, 2010 Thanks, but I get the following error: "Warning: Cannot modify header information - headers already sent by..." I didn't think that I could put a header() after the php had already started. Good idea, though.. Your processing script shouldn't generate any output, this way you can call header when its done. AHA! - I have some debugging "echo" statements in the script. I also found this way to do the same thing: print "<meta http-equiv=\"refresh\" content=\"0;URL=finish.php\">"; Thanks to everyone for the help!!!! Steve Quote Link to comment Share on other sites More sharing options...
pushpendra.php Posted February 4, 2010 Share Posted February 4, 2010 why don't you use header("location:url) and don't output anything before that not even a white space as it will give you 'headers already sent error', to bypass this error you can use php's output buffering functions. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 4, 2010 Share Posted February 4, 2010 Good work on answering a solved topic by repeating what's already been stated. Quote Link to comment Share on other sites More sharing options...
SteveMann Posted February 4, 2010 Author Share Posted February 4, 2010 Good work on answering a solved topic by repeating what's already been stated. If you are referring to Pushpendra's response, he *did* add to the solution. Steve Mann Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.