Yahoo probably has register_globals turned off, and rightly so. Try $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] instead, but I would rather go with && instead of ||.

Take a look at http://www.php.net/features.http-auth for more info.


Gohaku wrote:
Hi all,
I'm trying to implement "HTTP User Authentication" for some files but not directories.
Below is the following script I am using to test "HTTP User Authentication":


if ($PHP_AUTH_USER != "user" || $PHP_AUTH_PW != "pass")
{
  // visitor has not yet given details, or their
  // name and password combination are not correct

  header('WWW-Authenticate: Basic realm="Realm-Name"');

  header("HTTP/1.0 401 Unauthorized");

  echo "<h1>Go Away!</h1>";
  echo "You are not authorized to view this resource.";
}
else
{
  // visitor has provided correct details
  echo "<h1>Here it is!</h1>";
  echo "<p>I bet you are glad you you can see this secret page.";
}

The works on localhost but it doesn't work when uploaded to my Yahoo domain.
Please keep in mind that I am talking about Yahoo's Small Business Webhosting and not Geocities Webhosting.


Yahoo does provide Authentication but only for directories and not individual files.

just wondering if there's another way.
Thanks in advance.
-gohaku

-- Regards, Ben Ramsey http://benramsey.com

---------------------------------------------------
http://www.phpcommunity.org/
Open Source, Open Community
Visit for more information or to join the movement.
---------------------------------------------------

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to