set a redirect with set_header? |
[eluser]vitoco[/eluser]
i do my redirects with <? header('location:http://www.example.com'); ?>
[eluser]NogDog[/eluser]
The URL helper includes a redirect() function. If you want to use set_header(), as far as I can tell it's just like using PHP's header() function: Code: $this->output->set_header("Location: http://www.example.com/page.php");
[eluser]generalsalt[/eluser]
Hello, thanks for the response. I am seriously new to all this, so bear with me.... I have a basic else/if to check the Post variable for username/password indexes. If it finds them, I do this... Code: $this->load->library('session'); If it doesn't find them I do this... Code: $this->output->set_header('location: http://url.com/try_again'); But it doesn't redirect me to where I want to go, it just goes to the page that I am trying to password protect! I also tried this... Code: redirect('/try_again', 'refresh'); ...But I get a 'headers already sent' PHP error message. I'm reading up on all this stuff right now, If I have a eureka moment–I'll post back.
[eluser]generalsalt[/eluser]
Thought I'd post my code... Code: function Upload()
[eluser]NogDog[/eluser]
Any PHP function that sets/modifies headers must be executed before anything is output. That "anything" includes any text - even spaces or newlines - not within <?php...?> tags. Make sure that none of the files involved in this processing has any explicit output (echo, print, etc.) or accidental output. One "gotcha" can be any included files that have a newline after the closing "?>". It is therefore recommended that you omit the closing "?>" in all class definition and other include files for this very reason. |
Welcome Guest, Not a member yet? Register Sign In |