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 Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/ Share on other sites More sharing options...
roopurt18 Posted February 4, 2010 Share Posted February 4, 2010 header( 'Location: newpage.php' ); exit(); Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006555 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.. Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006589 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(); Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006594 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 Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006598 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. Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006600 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 Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006635 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. Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006638 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. Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006945 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 Link to comment https://forums.phpfreaks.com/topic/190872-can-i-open-a-new-page-when-the-form-processing-completes/#findComment-1006989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.