Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP Redirect without using header()


higgalls

Recommended Posts

Hey,

 

I have a script which updates all the products on my website.

After this script is finished, it needs to redirect to a new page.

Now, I cannot use the header() method of redirection because the headers are already sent to the browser.

 

I need to use a server side redirect as this script is running as a cron job, and because of that HTTP and Javascript redirects don't work.

 

Does anyone have any ideas on how I can get it all working?

 

I need to pass one variable through to the next script, which is being done via POST I think (i.e. it is sent via the URL).

 

Any help would be greatly appreciated. I am needing this resolve asap if possible.

 

Cheers,

Chris :)

Link to comment
Share on other sites

Try the following:

 

print "<script>";
print " self.location='mynewpage.html';";
print "</script>";

Regards,

 

Nacer.

 

Hey,

 

Thanks for your help.

I ended up getting it working very late last night using the header() thing. I needed to put ob_start(); at the top of my php script, and then just before where I want the header() redirect, I needed to put ob_end_clean();. This puts everything in a buffer and then flushes it if I need to do the header() call.

 

With the option you mentioned, I dont think that would work because I think it is javascript, and that is client-side, and not server-side.

 

Anyway, thanks for your help.

 

Cheers,

Chris

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...