Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_SERVER['REMOTE USER']

Status
Not open for further replies.

jivetrky

MIS
Jun 16, 2006
38
US
I'm new to PHP and am running into issues with
$_SERVER{'REMOTE USER']. If I run the following code, it returns blank.

<?php
$user=$_SERVER{'REMOTE USER'];
echo $user;
?>

Is there something I need to set in apache or PHP to get this to work?
 
Well first you need to make both brackets square brackets:

Code:
Change:
$user=$_SERVER[red]{[/red]'REMOTE USER'];

to

$user=$_SERVER[blue][[/blue]'REMOTE USER'];


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Sorry,

Typo on my part. I am using

$user=$_SERVER['REMOTE USER'];

and it still blank.
 
if the user is externally authenticated (such as by the webserver) the REMOTE_USER element will be populated.

so there are two reasons why your scripts might not be working:

1st (a definite) is that you are missing the underscore

2nd (a maybe) is that you need to be running an external authentication mechanism (such as .htaccess). browsers do not send user information unless explicitly asked to do so by the site (and it the browsers then pop's a dialog)
 
Ok, I've read a little about .htaccess. How do I set this up?
 
wrong forum, I'm afraid. we can help with php queries.

if you are using apache as your web server then you could post your query in the apache forum. I'm sure that there are lots of tutorials on the web for setting up access control in apache too.
 
jpadie,

I got .htaccess to work. I have another question. Do you know away through PHP I can get the remote user userid? What I'm trying to do is gather the remote user id and build an email address from the logon id. I have a request form built with mySQL & PHP. When the user submits their request, I want to have PHP send an email to the user that the request has been received.

Any ideas?

 
Create a page with the following in it...

<?php
echo '<pre>';print_r($GLOBALS);echo "</pre>";die;
?>

From there, you can get all of the super global information. You may have already done this, but this post might help someone else.

Mark
 
I think it's simply that you're missing an underscore:

Code:
Try changing: $user=$_SERVER['REMOTE USER'];

to 

$user=$_SERVER['REMOTE[COLOR=red]_[/color red]USER'];
 
roadcone20
I got it to work using .htaccess for apache. I had a typo in the thread. I was using $user=$_SERVER['REMOTE_USER']; It gave me the logon name I used for .htaccess. What I need is to gather the local user name from their PC. This way I can build an email address from it. The PHP code is on an Intranet site.

 
think of the security concerns in allowing the user's name from travelling across the internet... or even an intranet. that you cannot do unless ...

you use IE with IIS and have integrated windows authentication turned on.

also, if it is all on the same subnet you might be able to query a domain server through LDAP or similar.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top