php使用cookie實現(xiàn)記住用戶名和密碼實現(xiàn)代碼
更新時間:2015年04月27日 10:22:59 投稿:junjie
這篇文章主要介紹了php使用cookie實現(xiàn)記住用戶名和密碼實現(xiàn)代碼,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下
<meta http-equiv="Content-Type" content="text/html; charset=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/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=\"remember.php\">返回</a>";
?>
您可能感興趣的文章:
- 詳解PHP中cookie和session的區(qū)別及cookie和session用法小結
- thinkphp3.x中cookie方法的用法分析
- php通過curl添加cookie偽造登陸抓取數(shù)據(jù)的方法
- PHP基于cookie與session統(tǒng)計網(wǎng)站訪問量并輸出顯示的方法
- php使用CURL不依賴COOKIEJAR獲取COOKIE的方法
- php使用cookie實現(xiàn)記住登錄狀態(tài)
- php實現(xiàn)cookie加密的方法
- php使用cookie保存用戶登錄的用戶名實例
- php使用cookie顯示用戶上次訪問網(wǎng)站日期的方法
- PHP利用Cookie設置用戶30分鐘未操作自動退出功能
相關文章
Zend Framework教程之模型Model基本規(guī)則和使用方法
這篇文章主要介紹了Zend Framework教程之模型Model基本規(guī)則和使用方法,結合實例形式詳細分析了Zend Framework中模型的原理與具體使用技巧,需要的朋友可以參考下2016-03-03
php實現(xiàn)的支付寶網(wǎng)頁支付功能示例【基于TP5框架】
這篇文章主要介紹了php實現(xiàn)的支付寶網(wǎng)頁支付功能,結合實例形式分析了基于TP5框架框架的支付寶網(wǎng)頁支付功能具體操作步驟與相關實現(xiàn)技巧,需要的朋友可以參考下2019-09-09
用Laravel Sms實現(xiàn)laravel短信驗證碼的發(fā)送的實現(xiàn)
這篇文章主要介紹了用Laravel Sms實現(xiàn)laravel短信驗證碼的發(fā)送的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-11-11
Smarty foreach控制循環(huán)次數(shù)的一些方法
這篇文章主要介紹了Smarty foreach控制循環(huán)次數(shù)的一些方法,本文同時總結了一部分獲取當前次數(shù)的方法,需要的朋友可以參考下2015-07-07

