Category: Security and Cryptography
Authentication on Mac?
I am making a site that requires user authentication. It checks a database for the users username and password and only lets them in if they match. Apparently, my client is using a Mac, and she claims that she cannot log in to the site on that computer. She has a power MAC 7200/90 with system software of 7.5. She has Netscape
3.0. I am wondering if this problem is related to her Mac. My code is below. Thanks for any help.
Craig Anderson
Intrepid Web Site Development
canderson@intrepidwsd.com
<?php
if (!isset($PHP_AUTH_USER)) {
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($PHP_AUTH_USER)) {
mysql_connect("hostname", "username", "password")
or die ("Unable to connect to database.");
mysql_select_db("dev_i2ii_com")
or die ("Unable to select database.");
$sql = "SELECT *
FROM users
WHERE username='$PHP_AUTH_USER' and password='$PHP_AUTH_PW'";
$result = mysql_query($sql);
$num = mysql_numrows($result);
if ($num != "0") {
echo "<P>You're authorized!</p>";
exit;
} else {
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}
}
?>