Page 1 of 1

Header problem...

Posted: Wed Jun 02, 2004 9:33 pm
by augustus_emperor
here is my prob...
1st i include one file...

Code: Select all

<?php
include("password.php");
?>
Then this is my header function...

Code: Select all

<?php

if($login){
	if($user_name==$username && $password==$pass_word){
	header("location:main_admin_panel.php");}
	 
}
?>
what making i'm confuse is... this statement appear...

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/www/data-dist/application/admin/adminpanel.php:9) in /usr/local/www/data-dist/application/admin/adminpanel.php on line 70

Posted: Wed Jun 02, 2004 9:37 pm
by dull1554
you should google that, you will find tons about headers allready being sent

the reason you get this error is because you output html or such before you call the header, so you either cant write stuff to the screen before the header or you could use output buffering
ob_start()
search it
.....
good luck

Posted: Wed Jun 02, 2004 9:38 pm
by Guilherme Blanco
You must have to check if you didn't put any echo'ing or printing before assing the header.
I mean that your code can't have any white space, <html>, or something like this before the php code. If you echo'ed it, you cannot set the header.

You probably did it.

* NOTE:
I prefer to use header("Location: ...");
Location, with the uppercase in the first char of the "Location" string.


Regards,

Posted: Wed Jun 02, 2004 9:39 pm
by feyd
the output started here: adminpanel.php line 9

Posted: Wed Jun 02, 2004 9:56 pm
by tim
2 simple solutions

1.) Combine output buffering (as suggested) and dodge in n out of html n php tags

2.) use Javascripting, location.replace

:P

JS would be my route.