Jack Sorry - I am a bit confused... Are you saying you could not get a header() re-direct to work in a script that posts form data to itself? As someone else has mentioned the header() call does not have to be at the top of the script it just has to be executed before any output has gone to the browser...it could be the last line of a script.
BTW your javascript solution won't work if the user has switched off javascript... Rich -----Original Message----- From: Jack Kelly Dobson [mailto:[EMAIL PROTECTED]] Sent: 27 November 2002 16:20 To: [EMAIL PROTECTED] 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- "Cam Dunstan" <[EMAIL PROTECTED]> wrote in message 002801c29602$d3e50da0$7866a8c0@camhome">news:002801c29602$d3e50da0$7866a8c0@camhome... > Jack, > here is another quick and dirty function to stick in your library, yet > another way to redirect from anywhere in your script > > function redirect($url){ > echo "<script>window.location.replace(\"".$url."\")</script>"; > } > > usage: > > blah > blah > redirect("any_url"); > > exit; > > > > > > > -----Original Message----- > > From: Jack Kelly Dobson [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, November 26, 2002 2:43 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP-WIN] Redirect browser to another URL? > > > > > > Hello, > > > > Anyone know how to have a script re-direct the browser to a URL cleanly? > > > > -- 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