Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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