Jump to content

Header Issues


flyersun

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/83512-header-issues/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/83512-header-issues/#findComment-424907
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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