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
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
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
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
Share on other sites

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

 

I don't understand why you would want to output something to the browser if all your going to do is redirect to another page. That makes even less sense.

Link to comment
Share on other sites

If you send a header to redirect someone they won't even see the output (provided you're using OB, if you're not it'll just die) so there's no point in attempting what you're suggesting.

 

As Mchl said, if you want a pause, you can use meta tags or javascript.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.