Jump to content

stupid question about Header


robert_gsfame

Recommended Posts

i got this code

 

<?php require_once('config.php');?>

<?php if(isset($_POST['login'])){

if(empty($_POST['username'])||(empty($_POST['password']))){header('location:failure.php');}}?>

 

when i run it, then this statement appeared

CANNOT MODIFY HEADER(HEADER ALREADY SENT

 

can anyone find out which part is wrong?

thx

Link to comment
Share on other sites

The whole error message states where the output is occurring that is preventing the headers from working.

 

Reading the error message would indicate where to look. The problem is either characters or content being output from the files or due to the Unicode/UTF-8 BOM characters that an editor places at the start of the file. The problem could be with either the main file or the file being included.

Link to comment
Share on other sites

the second you break out of php and output markup OR whitespace headers are sent.

 

you can prevent this by coding so that all logic is executed/all processing done BEFORE you start building the page OR by using output buffering

 

buffering may not be the best option but if you have lots of legacy code it will solve it in the short term.

Link to comment
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.