Jump to content

Header not working


simpli

Recommended Posts

Hi, I have a form. It was validated, treatment was done data inserted in my db and I want to redirect the user to another page so I use

 

 header("http://localhost/showresults.php"); 

 

Nothing happens however. In the documentation they say header must be used before anything is output and I'm not sure I understand that. Does that mean that from the moment you have output something in your web page header will not work? Anyhow can someone tell me what I should use to redirect the users to the above page?

 

Thank you,

J-R

 

 

Link to comment
https://forums.phpfreaks.com/topic/150509-header-not-working/
Share on other sites

Ouput buffering does put a bit of an overhead on php generating your page, but it actually speeds up the browser rendering it(depending on how much code there is), and aided with page compression can increase loading times furthermore.

 

So depending on how much code you're sending to the page, OB can actually increase speed.

Link to comment
https://forums.phpfreaks.com/topic/150509-header-not-working/#findComment-790565
Share on other sites

This is valid use for output rendering. Using it to defer output so that heading can be send is not so good. It is much better to restructure the code, so that the headers are actually sent before any content (buffered or not). It's not that difficult usually.

Link to comment
https://forums.phpfreaks.com/topic/150509-header-not-working/#findComment-790570
Share on other sites

If I have already sent something to the page is there another function I can use to redirect the user to another page? I'm not sure I understand the usefulness of this function if we cannot use it after stuff has been output to the web page. If for instance I have a validation form that was created through php and then the form is validated ok and I want to write some data and then send it on to the next page. Technically data has been output to the page (The first time when i created the page). So how would/should I go about doing what I wanna do?

 

Thanks for clarifying.

J-R

Link to comment
https://forums.phpfreaks.com/topic/150509-header-not-working/#findComment-790689
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.