这只是html的代码,是没有“记住”的功能的。要实现这个功能还必须用到其它动态网站编程语言,如asp,php,jsp等,这些编程语言都有个叫“cookie”的东东,用来在客户端保存信息的,用它就能“记住”用户的选择了。
用COOKIE. 看看下面的对你有帮助没remember.php
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<form id="form1" name="form1" method="post" action="check_remember.php">
<table width="300" border="1" align="center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<td colspan="2" align="center"><b>记住用户名和密码</b></td>
</tr>
</thead>
<tr align="center">
<td>用 户 名:</td>
<td><input type="text" value="<?php echo $_COOKIE['name']?>" name="name"></td>
</tr>
<tr align="center">
<td>密码:</td>
<td><input type="password" name="password" value="<?php echo $_COOKIE['password']?>"></td>
</tr>
<tr align="center">
<td>记住用户名和密码</td>
<td><?php if($_COOKIE['remember'] == 1){?><input type="checkbox" name="remember" value="1" checked><?php }else{($_COOKIE['remember'] == "")?><input type="checkbox" name="remember" value="1"><?php }?></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="Submit" value="提交" /></td>
</tr>
</table>
</form>
check_remember.php
<meta http-equiv="Content-Type" content="text/htmlcharset=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 "<a href=\"remember.php\">返回</a>"
?>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)