代码:
<?php
if ($_POST[name]&&$_POST[password]){
$name=$_POST[name];
$pass=$_POST[password];
setcookie('id',$name);
setcookie('pass',$pass);
}
if ($_COOKIE[id]&&$_POST[pass]){
echo "登陆成功<br>用户 :".$_COOKIE[id]."<br>密码:".$_COOKIE[pass];
}
?>
<form action="" method="post">
用户:
<input type="text" name="name"><br><br>
密码:
<input type="password" name="password"><br>
<input type="submit" name="sub" value="登陆">
</form>
出现的错误:
Notice: Use of undefined constant name - assumed 'name' in C:\wamp\www\aa\test.php on line 2
Notice: Undefined index: name in C:\wamp\www\aa\test.php on line 2
Notice: Use of undefined constant id - assumed 'id' in C:\wamp\www\aa\test.php on line 9
Notice: Undefined index: id in C:\wamp\www\aa\test.php on line 9