flyersun Posted December 28, 2007 Share Posted December 28, 2007 I'm having an problem with using the following line on my website "header("Location: viewphotos1.php");" I need this line to be called half way down the page (after html ect) I know this doesn't work so I create a function: function goto() { header("Location: viewphotos1.php"); } And stuck this at the top of the page under my session_start(); line. Later on down the page if a users login information is correct they should be sent back to viewphotos1.php however I'm getting an error message. Warning: Cannot modify header information - headers already sent by (output started at /home2/amytucke/public_html/site/inc/header.php:14) in /home2/amytucke/public_html/site/login.php on line 6 Does anyone know a way around this? I figured using a function would work but I guess not. Quote Link to comment https://forums.phpfreaks.com/topic/83512-header-issues/ Share on other sites More sharing options...
GingerRobot Posted December 28, 2007 Share Posted December 28, 2007 It doesn't work like that. Just because your function is at the top of the page, the headers are still sent after the html is sent to the browser. You either need to rethink your logic (good option) or use output buffering. See here for some information on output buffering. Quote Link to comment https://forums.phpfreaks.com/topic/83512-header-issues/#findComment-424907 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.