php使用cookie实现记住用户名和实现代码
文章主要介绍了php使用cookie实现记住用户名和密码实现代码,本文直接给出实现代码,需要的朋友可以参考下。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form id="form1" name="form1" method="post" action="check_">
<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_
<meta http-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 "<a href="">返回</a>";
?>
-
php中zend相对路径问题
php下使用zend相对路径的处理方法。如何使用呢?就跟随本站小编一起去了解下吧,想了解更多相关信息请持续关注我们应届毕业生考试网!<?phpdefine('P_S',PATH_SEPARATOR);define('ROOT',"../");set_include_path(ROOT.P_S.'Zend'.P_S_incl...
-
PHP代码如何规范
对于PHP入门学习的童鞋来说,基础是很重的,一定要打好基础。那么大家知道PHP代码如何规范呢?下面一起来看看!了解PHP开发规范可以少走很多弯路,网上各种PHP开发规范也很多,我结合自身使用PHP的情况,来说说我所理解的PHP开发规范,涉及多个方面,比如PHP代码规范、PHP文件...
-
php是什么大纲
导读:时至今日,仍有无以数计的童鞋出于各种渠道了解仍要来学习php,那么对于新手来说,对php有一个清晰的认知则是很有必要的。Php是什么?PHP是一种创建动态交互性站点的强有力的服务器端脚本语言。PHP是免费的,并且使用非常广泛。同时,对于像微软ASP这样的竞争者来说,P...
-
tp搜索时首页分页和搜索页保持条件分页的方法
在做搜索查询时突然发现在首页用的`分页代码在搜索页使用时出现错误,首页分页代码(代码中标注start与end部分为分页代码),下面是由本站小编为大家整理的Thinkphp搜索时首页分页和搜索页保持条件分页的方法,喜欢的可以收藏一下!了解更多详情资讯,请关注应届毕业生...