做了个身份认证的验证程序不好用???急
我的系统在xp下+php4.34+mysql+apache
我根据书上面的例子也写了一个测试程序,出现了header调用的认证界面,但是我输入名字和密码总是得不到响应.
例子如下:
<?
function auth()
{
header("WWW-Authenticate: Basic realm=www.mysite.com");
header("HTTP/1.1 401 Unauthorized");
echo "<h2>您需要进行身份认证!</h2>";
echo "<br>请选择刷新!";
exit;
}
function showwelcome($msg="您已经通过身份认证!")
{
echo "<table border='0'>";
echo "<tr><td align='center'><h4>";
echo "<font color=#ff0000>".$msg."</font>";
echo "</h4></td></tr>";
echo "</table>";
}
if(isset($_SERVER['PHP_AUTH_USER']))
{
auth();
}
else
{ $user=$_SERVER['PHP_AUTH_USER'];
$pass=$_SERVER['PHP_AUTH_PW'];
mysql_connect("localhost","root","123") or die("unable to connect to databases!");
mysql_select_db("web_db");
$query="select user_id from http_auth where username='$user' or userpass=password('$pass')";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
if($numrows==0)
{
auth();
}
else
{
showwelcome();
}
}
?>
在网页上编译通过了,但不能显示我的输入结果,是正确的用户,还是不是!!它一直显示在登入!!!
为什么是这样的>急,在线等!!!!!