新手求助 cookie登陆问题
<?php
include("conn.php");
if($_POST[id]=='admin'){
$pw=md5($_POST[pw]);
if($pw=='a9c449d4fa44e9e5a41c574ae55ce4d9')
{
setcookie("cookie","ok");
echo "<script language="javascript">location.href='login.php';</script>";
}
}
if($_COOKIE['cookie']!='ok')
{
?>
<SCRIPT language=javascript>
function Checklogin()
{
if(myform.id.value==""){
alert("请填写登陆名");
myform.id.focus();
return false;
}
if(myform.pw.value==""){
alert("密码不能为空");
myform.pw.focus();
return false;
}
}
</SCRIPT>
<form action="" method="post" name="myform" onsubmit="return Checklogin();" enctype="text/plain">
id:
<input type="text" name="id" /><br>
pw:
<input type="password" name="pw" /><br>
<input type="submit" name="submit" value="登陆"/>
</form>
<?php
}
else
{
?>
<a href='?out=login'>退出</a>
<?php
}
?>