Re: Trouble with PHP server script
| From: | Nathan Rixham | Date: | Mon, 11 Feb 2008 11:10:30 +0000 |
| Subject: | Re: Trouble with PHP server script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269072@lists.php.net to get a copy of this message | ||
Robert Cox wrote:
Is it possible to use the "$_SERVER['PHP_AUTH_USER'];" construct in a URL
forwarded site? I am trying to find the authorised user id so that I can
access an SQL database with it. Anyone got some ideas?
PHP looks like this....
<?php
//Get User
$user = $_SERVER['PHP_AUTH_USER'];
// Get User type
$db = mysql_connect(localhost, ....., .....) or die("Can't connect to
database: ".mysql_error());
mysql_select_db(................) or die("Can't select database:
".mysql_error());
$query = "SELECT * FROM user WHERE staffid LIKE $user";
$result = mysql_query($query) or die ('Not a valid User: ' .
mysql_error());
....
?>
Robert,
print_r($_SERVER); will answer all your questions :)
Nathan