Jump to content

PHP Redirect


rorybing

Recommended Posts

Hi,

 

I'm trying to figure out if I can get a redirect page to work, without needing to use the header("Location: page.php"); command.

 

I know with asp, there is a response.redirect for redirecting pages, but, with the header, I can only use this, if there is no output before calling the command.

 

Is there any method that can be used where I can process some code, if output is required, and depending on processing on the page, redirect it to another page, using a command similar to response.redirect?

 

I have seen the http_redirect, but I can only see this working with clearing buffers etc. I have also a redirect_to("page.php"); command, but I cannot get this to work.

 

I am using php 5.

 

Any help would be appreciated.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/256333-php-redirect/
Share on other sites

asp uses output buffering to get around the problem with header redirects, the asp redirect is the same command.

 

You can use ob_start to start output buffering, make your decision, and if you need to redirect, kill the buffer and send the header.

Link to comment
https://forums.phpfreaks.com/topic/256333-php-redirect/#findComment-1314063
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.