Jump to content


other means to redirect to another page..

  • Please log in to reply
6 replies to this topic

#1 gardan06

  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 03 October 2006 - 06:59 PM

well, i'm having trouble with the header() function, as i always get a "headers already sent" message. so i was wondering..

are there other ways of redirecting someone to another page aside from using the header function?

#2 Daniel0

  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 03 October 2006 - 07:01 PM

Use output control: http://php.net/outcontrol

The reason of the error is that you output something before sending a header, and you can't do that since headers are the very top of the HTTP request.

#3 micah1701

  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 03 October 2006 - 07:02 PM

You can use a <META> Tag in your HTML or JavaScript (if the user has it turned on)

"Confidence in the face of risk."

#4 obsidian

  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 03 October 2006 - 07:06 PM

the best way is just to handle your logic before you send any header information to the browser if at all possible. this is much more easily handled in larger scripts by using templates or some other sort of control to allow you to determine when the output is actually sent.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 roopurt18

  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 03 October 2006 - 07:10 PM

Instead of constantly echo'ing output from PHP, try appending it into a single $Page or $HTML variable.  At the very end of your script echo that single variable and you should be set.
PHP Forms : Part I | Part II

JavaScript: Singleton


#6 gardan06

  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 03 October 2006 - 07:20 PM

cool, i used ob_start on the page that says it already sent headers, and it worked. thanks guys ^^

#7 saiko

  • Members
  • PipPipPip
  • Advanced Member
  • 37 posts

Posted 04 October 2006 - 09:23 AM

put ob_start(); at the start of ur page then ob_end_flush(); at the end :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users