473,468 Members | 1,323 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Weird authentication issue

All:

I have an application that has been working well for 3-4 months now
without any issues (that I am aware of). A day or two ago, one of our
employees that use this application called to say she was getting a
weird message:

"Warning: Cannot modify header information - headers already sent by
(output started at /www/htdocs/sys36/viewhist.php:2) in
/www/htdocs/sys36/viewhist.php on line 5"

I have been looking into the problem and apparently, the problem is due
to authentication. Going to other parts of the site will trigger a
prompt for username/password and once that is entered, all is well,
even with the page above.

The puzzle is that all pages using Auth use the *EXACT SAME CODE*:

if (!isset($PHP_AUTH_USER)) {
// if empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($PHP_AUTH_USER)) {

// if non-empty, check the database for matches
// Connect to the database
$db = mysql_connect("host", "user", "password");
mysql_select_db("sys36",$db);

$sql="SELECT * FROM Auth WHERE userid='$PHP_AUTH_USER' and
password='$PHP_AUTH_PW'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$myrow = mysql_fetch_array($result);
$userlevel=$myrow["level"];

if ($num != "0") {
} else {
$userlevel="3";
}
}

Can anyone shed any light on this?
Thanks!
rk

Jul 17 '05 #1
5 1670
redneck_kiwi wrote:

All:

I have an application that has been working well for 3-4 months now
without any issues (that I am aware of). A day or two ago, one of our
employees that use this application called to say she was getting a
weird message:

"Warning: Cannot modify header information - headers already sent by
(output started at /www/htdocs/sys36/viewhist.php:2) in
/www/htdocs/sys36/viewhist.php on line 5"

I have been looking into the problem and apparently, the problem is due
to authentication. Going to other parts of the site will trigger a
prompt for username/password and once that is entered, all is well,
even with the page above.

The puzzle is that all pages using Auth use the *EXACT SAME CODE*:

if (!isset($PHP_AUTH_USER)) {
// if empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($PHP_AUTH_USER)) {

// if non-empty, check the database for matches
// Connect to the database
$db = mysql_connect("host", "user", "password");
mysql_select_db("sys36",$db);

$sql="SELECT * FROM Auth WHERE userid='$PHP_AUTH_USER' and
password='$PHP_AUTH_PW'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$myrow = mysql_fetch_array($result);
$userlevel=$myrow["level"];

if ($num != "0") {
} else {
$userlevel="3";
}
}

You must have some kind of output before that first line. Check for anything
being echoed or even a blank line before your first <?PHP tag.

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #2
Thanks Shawn....the ONLY thing is <!DOCTYPE HTML PUBLIC "-//W3C//DTD
HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
This is the same line as the page that DOES work!

:-)

Jul 17 '05 #3
redneck_kiwi wrote:
Thanks Shawn....the ONLY thing is <!DOCTYPE HTML PUBLIC "-//W3C//DTD
HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
This is the same line as the page that DOES work!

:-)


When you output the doctype line the headers get definitely sent. You have
to move this line below the authentication lines.

It is actually strange that the other page works. Are you sure you tested it
when $PHP_AUTH_USER was not set? It looks to me as if the authentication was
usually made on a page with no output before the authentication, then the
buggy one did not show the problem, because it did not have to send a
header.

--
Markus
Jul 17 '05 #4
In article <10**********************@f14g2000cwb.googlegroups .com>,
"redneck_kiwi" <kf****@gmail.com> wrote:

:This is the same line as the page that DOES work!

Has your user/employee "bookmarked" her login? Is she sending GET data
straight to the page she wants to view? Someone here can explain that
better than me for sure.

Otherwise:
http://ca3.php.net/manual/en/ref.outcontrol.php
http://ca3.php.net/manual/en/function.ob-start.php
--
Looks like more of Texas to me ...
-- from The Wild Bunch
Jul 17 '05 #5
Odd thing is that moving the doctype line below the auth section
results in a parsing error. Removing the doctype line entirely fixes
the problem!

also, in order to troubleshoot the problem, I use a browser and can
duplicate her results.

Thanks for the pointer, (re)moving the doctype fixed the problem....odd
that it doesn't cause problems with the other pages.

rk

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed...
2
by: Rob Mayo | last post by:
What I'm trying to do is Create an ASP.Net app that has both Windows-authenticated users and Anonymous users. The idea is this: When authenticated users attempt to access the site, their...
2
by: CW | last post by:
I have run into a really strange problem. My objective is that I only want user who have authenticated themselves to be able to access the website (and authentication is performed by form...
4
by: Chris Gatto | last post by:
Hi, I'm having what should be a minor problem but has turned into a 2 day slug fest with ASP.Net. I am simply attempting to authenticate my asp.net application users against users in an AD...
5
by: Nevets Steprock | last post by:
I have been building a website diligently for the past three months and everything has been working well so far. Yesterday, I added a link on my javascript menu. This link is supposed to go to a...
2
by: Matt | last post by:
I am getting the following Error. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific...
5
by: David Thielen | last post by:
Hi; Ok, I will be the first to agree that this should be impossible - except we are able to keep repeating it. Our login page - which has moderately complex html and uses <LayoutTemplate> to...
4
by: =?Utf-8?B?R3V1czEyMw==?= | last post by:
Hi, I created a web site on a remote server. To logon the user must enter a user id and password. The site is uses Forms Authentication. The web config file looks as follows: ...
0
by: embeddedbob | last post by:
Hi there, I appreciate any help on the following issue. I can't seem to find any other similar topic. (CS4, ActionScript 3.0, Flash 10) I have a SWF embedded within a page that is protected by...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.