啥问题造成的呢?
<?
ob_start();
require("config.php");
$user_array = file($userdatafile);
$user_num = count($user_array);
$username = $_POST["username"];
$passwd = $_POST["passwd"];
//验证用户名和密码是否为空:
if($username == "")
{
echo"<meta http-equiv=refresh content=7;URL='javascript:history.back(1);'><br><br><br><br><font size=3>请输
入<font color=ff0000>用户名</font></font><br><a href=javascript:history.go(-1);>返回</a><br><br><br>";
exit;
}
if($passwd == "")
{
echo"<meta http-equiv=refresh content=5;URL='javascript:history.back(1);'><br><br><br><br><font size=3>请输
入<font color=ff0000>用户密码</font></font><br><a href=javascript:history.go(-1);>返回</a>";
exit;
}
//验证登陆用户信息:
for($i = 1;$i<$user_num;$i++)
{
list($name,$pwd,$admin)=explode("|",$user_array[$i]);
if($username == $name and $passwd != $pwd)
{
echo "密码错误!";
exit;
}
if(($username != $name) and ($i == $user_num-1))
{
echo "此用户不存在!";
exit;
}
}
//创建cookie:
setcookie("username",$username);
setcookie("passwd",$passwd);
echo "登陆成功!";
ob_flush();
?>
这是个登陆验证文件,
不知道为什么
if(($username != $name) and ($i == $user_num-1))
{
echo "此用户不存在!";
exit;
}
这句怎么不起作用,随便填个不存在的用户名密码就提示登陆成功