<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<formid="form1"name="form1"method="post"action="check_remember.php">
<tablewidth="300"border="1"align="center"cellpadding="0"cellspacing="0">
<thead>
<tr>
<tdcolspan="2"align="center"><b>记住用户名和密码</b></td>
</tr>
</thead>
<tralign="center">
<td>用户名:</td>
<td><inputtype="text"value="<?phpecho$_COOKIE['name'];?>"name="name"></td>
</tr>
<tralign="center">
<td>密码:</td>
<td><inputtype="password"name="password"value="<?phpecho$_COOKIE['password']?>"></td>
</tr>
<tralign="center">
<td>记住用户名和密码</td>
<td><?phpif($_COOKIE['remember']==1){?><inputtype="checkbox"name="remember"value="1"checked><?php}else{($_COOKIE['remember']=="")?><inputtype="checkbox"name="remember"value="1"><?php}?></td>
</tr>
<tralign="center">
<tdcolspan="2"><inputtype="submit"name="Submit"value="提交"/></td>
</tr>
</table>
</form>
check_remember.php
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<?php
$name=$_POST['name'];
$password=$_POST['password'];
$remember=$_POST['remember'];
if($remember==1){
setcookie('name',$name,time()+3600);
setcookie('password',$password,time()+3600);
setcookie('remember',$remember,time()+3600);
}else{
setcookie('name',$name,time()-3600);
setcookie('password',$password,time()-3600);
setcookie('remember',$remember,time()-3600);
}
echo"<ahref=\"remember.php\">返回</a>";
?>