Ahhh yes .... I have seen this mentioned somewhere, and yet I can't remember where right now. This is the output buffering that lets you even put header content after page content and still have it appear before, isn't it?
If I remember correctly, this is controlled by setup on the server, right? A setting in the php.ini file that controls this? If so ... I may have to plead with my web host, I don't actually own and run the server my site is hosted on ... but definitely something I'll do some more reading on I am pretty much a newbie, having taught myself what I need to know, and I've done some major experimenting ... I haven't even gotten into some of the more complex functions of PHP. I used to have my site primarily coded in Javascript/DHTML, and I basically adopted what I was trying to do with DHTML into Javascript if that tells you the complexity I'm currently working on. I've only started playing with file functions, to say nothing of databases. ... ----- Original Message ----- From: "Ignatius Reilly" <[EMAIL PROTECTED]> To: "Stephen Edmonds" <[EMAIL PROTECTED]>; "PHP Helplist Windows" <[EMAIL PROTECTED]> Cc: "Max Graham" <[EMAIL PROTECTED]> Sent: Thursday, November 28, 2002 6:32 AM Subject: Re: [PHP-WIN] Redirect browser to another URL? > I concur with Stephen. However, there is an EXTREMELY simple and convenient > way to control output - that has not been mentioned in this thread: > start all your PHP scripts with : > ob_start() ; > > then you can pepper your script with one < header:Location... > statement > EVERYWHERE you want (in my case I redirect to custom error pages) > > when you are done (at the end of the display form that follows the > validation script), output the buffered content: > ob_end_flush() ; > > HTH > Ignatius > ____________________________________________ > ----- Original Message ----- > From: "Stephen Edmonds" <[EMAIL PROTECTED]> > To: "PHP Helplist Windows" <[EMAIL PROTECTED]> > Cc: "Max Graham" <[EMAIL PROTECTED]> > Sent: Thursday, November 28, 2002 2:21 PM > Subject: Re: [PHP-WIN] Redirect browser to another URL? > > > > if ( $FormIsSent == "My-String ) { > > process form > > header( "Location: url" ); > > } > > else { > > display form > > <input type = "hidden" name = "FormIsSent" value = "My-String"> > > } > > > > I use this technique on my sites all the time. The only restriction is you > > can't have any output before the header. If there is an error in the form, > > store it in an error variable: > > > > $error[NameForError] = "Problem with form"; > > > > then use a foreach to get the values back out > > > > if ( count( $error ) ) { > > foreach ( $error as $key=>$value ) { > > print "Error with $key - $value<br>"; > > } > > } > > else { > > header( "location: http://youurl.com/formsuccess.php" ); > > exit; > > } > > > > ----- Original Message ----- > > From: "Max Graham" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Thursday, November 28, 2002 5:50 AM > > Subject: Re: [PHP-WIN] Redirect browser to another URL? > > > > > > > You know, this is exactly what happened to me. I was trying to design a > > > comments page for a weblog to open in a popup. The page had a submission > > > form that would submit back to itself. 'course, I was banging my head on > > the > > > wall trying to come up with a way to get the page to detect whether it > had > > > received a form submission and write the comments to a comment file, and > > > then include the comment file with the form afterwards. I kept coming up > > > with the results of fopen(), fputs(), fflush(), and fclose() coming back > > as > > > false, which equals failed. I eventually did go to a separate page to do > > the > > > file writing, and that page finishes up with a 1-second delay using the > > > javascript setTimeout() for this command in a standalone function: > > > > > > echo "location.replace('blogcomments.php?target=".$target."');\n"; > > > > > > Inelegant, but it works. I haven't had too much experience with the > header > > > function, and knowing how long it took me to bang this one out, I might > > set > > > something on fire trying it :) > > > > > > Anyone else had any fun with this issue? > > > > > > Message-ID: <[EMAIL PROTECTED]> > > > To: [EMAIL PROTECTED] > > > Reply-To: "Jack Kelly Dobson" <[EMAIL PROTECTED]> > > > From: "Jack Kelly Dobson" <[EMAIL PROTECTED]> > > > Date: Wed, 27 Nov 2002 10:19:30 -0600 > > > Subject: Re: [PHP-WIN] Redirect browser to another URL? > > > > > > Thanks for all the help guys. > > > > > > My problem, as most of you figured, is that my script has a form in it > > that > > > re-runs itself when the form is submitted so there is only one script > > > including the form and all the validation for the form. If the > validation > > is > > > successful it sends you to a different page depending on the information > > > posted in the form. There was therefore no way I could get the header() > to > > > be at the top of the returned data. > > > > > > I ended up using: > > > > > > if ($condition) { > > > print("<SCRIPT LANGUAGE='JavaScript'>window.location='" . $url . > > > "'</SCRIPT>"); > > > } > > > > > > A rather elegant solution I've decided. > > > > > > Oh, and FYI to all you IIS users out there... (At least I'm assuming > it's > > > IIS and not the Windows platform itself. I'd be interested to know what > > > Windows users running Apache are experiencing). > > > > > > I didn't have this problem with my script until I migrated it to a > > > Linux/Apache platform. > > > > > > I assume that means that when I was doing it the original way that I had > > > multiple sets of header information and no telling what else being sent > > back > > > to the browser and IIS wasn't producing any error. Anyone using IIS and > > the > > > header(location: '') function might want to make sure they aren't > exposing > > > data they didn't mean to. > > > > > > j- > > > > > > > > > > > > -- > > > PHP Windows Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php