home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Can't modify header info??

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2067
Discussions: 200,950, Posts: 2,379,426, Members: 246,311
Old January 18th, 2003, 01:49 AM   Digg it!   #1 (permalink)
Ultimate Member
 
willy_ph's Avatar
 
Join Date: Oct 2001
Location: Trent University
Posts: 2,414
Can't modify header info??

I've been trying to setup a simple login page using php and a mysql database on a windows server using php 4.3.0.

Once if got all the code written, it keeps telling me that I can't modify the header info. This is the error that is produced.

Quote:
Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\login.php:8) in c:\inetpub\wwwroot\login.php on line 10

Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\login.php:8) in c:\inetpub\wwwroot\login.php on line 11

Sorry - you need valid credentials to access this resource.

The following is the code that I'm using.
PHP Code:
<?php 
    
if (!isset($_SERVER['PHP_AUTH_USER'])) {
        
header("WWW-Authenticate: Basic realm=\"The Willycorp Network\"");
        
header("HTTP/1.0 401 Unauthorized");
        
// only reached if authentication fails
        
echo "Sorry - you need valid credentials to access this resource.\n";
        exit;
    } else {
        
mysql_connect("localhost","*******","*******");
        
mysql_select_db("test");
        
$result mysql_query("SELECT ID FROM userauth WHERE Username = '{$_SERVER['PHP_AUTH_USER']}' AND Password = '{$_SERVER['PHP_AUTH_PW']}';");
        if (
mysql_num_rows($result)) {
        
// only reached if authentication is successful
        
echo "Welcome to the Willycorp Network.";
    } else {
        
header("WWW-Authenticate: Basic realm=\"The Willycorp Network\"");
        
header("HTTP/1.0 401 Unauthorized");
        echo 
"Sorry - you need valid credentials to access this resource.\n";
     }
    }
?>
Anyone have any idea what the hell is going on with this code?
willy_ph is offline   Reply With Quote
Old January 18th, 2003, 10:46 AM     #2 (permalink)
Ultimate Member
 
willy_ph's Avatar
 
Join Date: Oct 2001
Location: Trent University
Posts: 2,414
Bump for some help?!
__________________
The difficulty is to try and teach the multitude that something can be true and untrue at the same time. -- Arthur Schopenhauer
willy_ph is offline   Reply With Quote
Old January 18th, 2003, 03:12 PM     #3 (permalink)
Ultimate Member
 
willy_ph's Avatar
 
Join Date: Oct 2001
Location: Trent University
Posts: 2,414
You've gotta be kidding me. 13 views and no one knows how to help me out?!
willy_ph is offline   Reply With Quote
Old January 18th, 2003, 03:18 PM     #4 (permalink)
Ultimate Member
 
crouse's Avatar
 
Join Date: Jun 2002
Location: Iowa
Posts: 2,879
Send a message via ICQ to crouse
Are there actual authorized users and their passwords listed in the mysql database??

Might try clearing cookies out of your browser also.... ??

Check the database and make sure none of the info in is corrupted.

Just random thoughts....... hope they help.
__________________
USA Linux Users Group
OpenSUSE.us
crouse is offline   Reply With Quote
Old January 18th, 2003, 11:53 PM     #5 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
is 27 views gonna help you?

Quote:
Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\login.php:8) in c:\inetpub\wwwroot\login.php on line 10

hint : it's line 8 of your script.
hint: it's line 10 of your script.
hint: why are modifying header info already sent?
qball is offline   Reply With Quote
Old January 23rd, 2003, 05:39 PM     #6 (permalink)
Member
 
Clown's Avatar
 
Join Date: Jan 2002
Posts: 83
Are YOU logged in?
__________________
CLOWN
Clown is offline   Reply With Quote
Old January 23rd, 2003, 09:37 PM     #7 (permalink)
Ultimate Member
 
willy_ph's Avatar
 
Join Date: Oct 2001
Location: Trent University
Posts: 2,414
I got this figured out the otherday, should've posted back. I had the <html> tag at the beginning that was sending the header for the html info. I deleted that and then it worked fine.

Unfortunately, I still can't get the code to authorize from the database. Also, see this thread for some additional problems. I think there's an incompatibility somewhere with the authorization thing I'm trying to use and IIS 5.1. Any help you guys can give would be appreciated.
willy_ph is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Making Health Care Worse (176)
Is It Just Me? (2940)
The disrespect of Obama by Russian .. (29)
Wireless Televisions. (12)
windows 7 problem (7)
CPU fan stops spinning randomly (8)
Regular Build (6)
radeon x850xt platinum & shader.. (6)
Is the PSU I received dead? (12)
Print spooler problem (15)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (11)
windows vista security holes (9)
Dept. of HS: NSA 'Helped' Develop V.. (15)
Recent Discussions
Multiple Restarts Required at Boot (2)
Ideal cheap graph card for PC-Gaming? (18)
radeon x850xt platinum & shader 3 (6)
Graphics Card Upgrade Question (4)
For Sale BFG GTX285 OC2 with 10 year .. (3)
Point and Shoot Camera Suggestions. (3)
How to convert MP3's (4)
Wireless Televisions. (12)
Laptop with wireless problem. (2)
Internet Lost (1)
Hp Artist Edition + Matching Bag (0)
My monitor won't turn on after instal.. (0)
Asus P4G8X Mobo (6)
Xbox 360 GTA: SA disk error (1)
Is the PSU I received dead? (12)
windows 7 internet problem (5)
BSOD On Startup (ntoskrnl.exe) (2)
Print spooler problem (15)
Have you switched yet? (86)
screen resolution vs monitor size (2)
sms storage to PC (0)
Regular Build (6)
Open With ..... Win7 (0)
java code for fibonacci (1)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (35)


All times are GMT -4. The time now is 11:13 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28