Jump to content

Recommended Posts

hey everyone.

 

i'm getting this error:

Warning: Cannot modify header information - headers already sent by

 

i know its because the code is not the first line but there is no way for it to be on the first line because the code has this:

if ($check == 1)
   {
     header("location: domainform.php");
	 }
	 Else {
	 header("location: payment.php");
	 }

 

so is there anyway to redirect someone with php without useing header?

Link to comment
https://forums.phpfreaks.com/topic/195758-godaddy-header-problem/
Share on other sites

The error message does not mean that the header() function must be the first line of code.  It just has to be executed before any output is sent (to the browser).  Output is sent when you call echo, print() or other functions that send information.  If an error occurs and error_reporting is on, errors are sent to the browser.  Anything, ANYTHING including blank lines or spaces that are outside of the php tags (<?php ... ?>  or  <? ... ?>) is automatically sent to the browser.

 

Check everything above the code that is calling the header() function.  Also check all included files.  One common cause is when there is a line-feed (or carriage-return) after the last closing tag "?>" in an included file.  A common solution to this, is to just not include the closing tag in the included files.  You'll have to decide for yourself whether that is a hack or not.

 

Also make sure there is NOTHING BEFORE the first opening php tag.

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.