General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 9th, 2003, 05:23 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
header error

ive created a login script with 4 different levels...when you login it checks the users name against the databse and determines what level they are.... after i press login i get this error message then i get the info im supposed to be getting

Warning: Cannot modify header information - headers already sent by (output started at /home2/bruski/public_html/index.php:4) in /home2/bruski/public_html/auth.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /home2/bruski/public_html/index.php:4) in /home2/bruski/public_html/auth.php on line 24

lines 24 and 25 are as followed:

PHP Code:
 setcookie('username'$_POST['username'],  (time()+2592000), '/'''0);
        
setcookie('auth_level'$_POST['auth_level'], (time()+2592000),  '/'''0); 


thx...is it the cookie header thats being sent out or something else?

Reply With Quote
  #2  
Old September 9th, 2003, 06:03 PM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
Definitly something else. Obviously something has already sent headers on line 4 (it staits so in your error message). So check the script if you are outputing anything that might cause the headers to be sent (any echo, print, even a blank space will mess things up for you). Check and if you don't find the problem, post up to the 4th line here.

Another possibility would be to use ob_start() and ob_end_flush().

Hope it helps.

Reply With Quote
  #3  
Old September 9th, 2003, 06:09 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
4th line of the index? if thats the case here it is

<style type="text/css" title="currentStyle">
@import "./style.css";
</style>

Reply With Quote
  #4  
Old September 10th, 2003, 05:17 AM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
Quote from the manual for setcookie():
Quote:
setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.

In PHP 4, you can use output buffering to send output prior to the call of this function, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files.


You cannot output anything before you call setcookie(). Put anything that has to do with cookies before that 4th line. That should do the trick. Otherwise check the menitioned functions to work around this problem (ob_start() & ob_end_flush()).

Last edited by _rainbow_ : September 10th, 2003 at 05:45 AM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > header error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway