Solarpitch Posted April 7, 2007 Share Posted April 7, 2007 Hey guys, I am looking to use "header("Location:index.php");" in my code. Basically this will be called when the user logs in to redirect them to the home page but as you expect I get the usual "headers already sent message" Just wondering how to get around this? Do I use the ob_start() method or something? Not quite sure myself Cheers, Ger. Link to comment https://forums.phpfreaks.com/topic/46055-sending-header-info-after-html/ Share on other sites More sharing options...
fert Posted April 7, 2007 Share Posted April 7, 2007 yes you would use ob_start Link to comment https://forums.phpfreaks.com/topic/46055-sending-header-info-after-html/#findComment-223749 Share on other sites More sharing options...
Solarpitch Posted April 7, 2007 Author Share Posted April 7, 2007 Hey, I kinda had an idea alright but I am not sure how you would use it? Would it be something like... function redirect() { header("Location:index2.php"); } ob_start("redirect"); Link to comment https://forums.phpfreaks.com/topic/46055-sending-header-info-after-html/#findComment-223752 Share on other sites More sharing options...
fert Posted April 7, 2007 Share Posted April 7, 2007 <?php ob_start(); echo "HTML"; header("Location: page.php"); ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/46055-sending-header-info-after-html/#findComment-223754 Share on other sites More sharing options...
Solarpitch Posted April 7, 2007 Author Share Posted April 7, 2007 Thanks for that! Link to comment https://forums.phpfreaks.com/topic/46055-sending-header-info-after-html/#findComment-223758 Share on other sites More sharing options...
iman Posted April 7, 2007 Share Posted April 7, 2007 I am experiencing similar problems with "Warning: Header may not contain more than a single header, new line detected in lib.php line 156" This is the lib that runs thousands of pages but we recently upgraded our php and mysql and now I am getting these errors. Authentication is performed at a login screen with the lib as an include which is listed just above the auth section in top of page. I attempted to inset the ob_start & ob_end_flush lines you referred to in the lib where it references the redirect code but couldn't get it to work. I also did the same thing with the login page at the web site in the <php section and didn't work either. Any ideas what I am doing wrong? Link to comment https://forums.phpfreaks.com/topic/46055-sending-header-info-after-html/#findComment-223819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.