Header problem...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
augustus_emperor
Forum Newbie
Posts: 6
Joined: Tue Apr 20, 2004 9:20 pm

Header problem...

Post 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
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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
Guilherme Blanco
Forum Newbie
Posts: 12
Joined: Wed Jun 02, 2004 4:58 pm
Location: São Carlos - SP/Brazil
Contact:

Post 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,
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the output started here: adminpanel.php line 9
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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.
Post Reply