PHP header() problems

Harlan

New Member
Messages
3
Reaction score
0
Points
0
Relevant Info: adfree subdomain @ exofire.net, on STARKA server(I'm assuming it's a server?)

Problem:
test.php won't work.

test.php: Simply consists of..
Code:
<?php
header("Location: login.php");
?>

Error Message:
Warning: Cannot modify header information - headers already sent by (output started at /home/harlanw/public_html/test.php:1) in /home/harlanw/public_html/test.php on line 2

I'm assuming that there's a setting/default on the subdomains that is messing the header() function up; I just don't know what it is.

Anyone know what could be wrong?
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
That sort of error usually occurs because you have a space before your '<?php' tag. Check that you have no empty space there. You could also check the encoding of that file, sometimes if you are using the wrong encoding in your text then there can be some text before that tag when you save it.
 

Harlan

New Member
Messages
3
Reaction score
0
Points
0
I've checked both of course.

Could you make your own test.php and see if it works?
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Try to write a completely knew test.php file.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
Put ALL your PHP code before the website. The header must be called before the browser interprets the page.
 

akkudreamz

New Member
Messages
183
Reaction score
0
Points
0
If you intend to redirect to another page i won't suggest you using that way
use something like this

PHP:
function redirect($time,$topage)
{
	echo "<meta http-equiv='refresh' content='{$time}; url={$topage}' /> ";
	exit();
}


$time is the number of seconds to wait before redirecting
$page is the url of the page to redirect to

now all you need to is

PHP:
redirect(0,"login.php");
 
Last edited:
Top