Php Redirect After Header - A Twotsi Page
The Word On The Street Is...TWOTSI!

Php Redirect After Header

Php Redirect After Header
I got really upset with everybody telling me that I could not do this and having to write convoluted and difficult to maintain code in order to comply with the rule that the PHP Header redirect cannot be used after the page headers have been sent. Sorry but anybody who told you that you cannot redirect pages at any time from PHP is wrong,wrong,wrong! Now you can redirect PHP pages at ANY time in a script.

Sometimes you just want to find a way around the limitations - well here is how to exit to another PHP or HTML URL from anywhere in your script. It saves an awful lot of effort especially in logout scripts or security scripts! Here is the PHP code fragment that makes it all happen.



The first line is an inline print directive that simply prints everything between it and the end flag (scendx) to the surfers web browser. Dont forget that the end flag must be at the start of the line with no space characters before or after it and should be followed by a semi-colon on the line beneath.

This places a tiny javascript fragment into the page which is the actual instantaneous redirect - it takes a standard URL and so of course can be built with query strings etc. You can even use $ variables within the print command so you could build a flexible and powerful redirection scheme from what is essentially a piece of code from a framebreaker script. Finally just in case the surfer is one of the 1% or so who browse without javascript a noscript tag is included to allow the the surfer to follow a link.

Finally the exit command wraps up the page you have started to send to the browser, making it execute the jscript redirect.

Over the last few months this has saved me from having to write some really stupidly organised code on my web cams site and my webmasters co-operative free advertising site and since I could not find the method elsewhere I present it here. For those of you who have never tried the inline print function then give it a go - that can save a huge amount of coding too!
Php Redirect After Header page stats: viewed 1919 times | created 05 Jan 2011 | rated OK (53) by 372 users.


Latest Twotsis on Php Redirect After Header


wheres is the beat? i dont dont find it ummkay south park is the best with a beat ok a beat will be a beat with a beat

Twotsi on Php Redirect After Header by: Anonymous Dated: 28 Jun 2011 Scoring 25 points from 0 users.

Do you agree with this Twotsi: or


Twotsis on Php Redirect After Header by Rating



Owned by
System

Click to rate this page.

Share |

Anybody can add a page like this to Twotsi!


or Hints
Suggested Pages

Related Pages

Tags

This site is free but you may wish to donate or something to keep it that way!

People who Link Here:
[http://www.twotsi.com/php-redirect-after-header]

Bookmark - [247]
Www.webmaster-a.com [248]
Searchengine - [2]

Last Link in: Bookmark

To get your site listed here, link to us and send us traffic. Links back to good sites (ie not medic@1, p0rn or sp@m related) will appear within a day or so but ONLY if your link to us is visible and sends traffic. After a few days with no traffic it will vanish.

Friendly Sites


Ads by - Free Advertising