记住密码前台禁止自动填充
<div class="form"> <form method="post" name="videoform" id="videoform" action="" ><input type='text' style='display:none'> <div class='checkuser'> <img src="__PUBLIC__/Hospital/images/u1.png" alt=""> <input type="text" placeholder="请输入账号" class="login_txtbx" name='username' id='username' value="{$jz_login['jz_username']}" required data-msg-required="请输入账号" autocomplete='off' /> </div> <div class='checkuser'> <img src="__PUBLIC__/Hospital/images/u2.png" alt=""> <input type="password" placeholder="请输入密码" class="login_txtbx" name='password' id='password' value="{$jz_login['jz_pwd']}" required data-msg-required="请输入密码" autocomplete="new-password" style="background-color: #FFFFFF!important;" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly',true);"/> </div> <div class="checkcode"> <p> <img src="__PUBLIC__/Hospital/images/u3.png" alt=""> <input type="text" placeholder="验证码" maxlength="4" class="login_txtbx" name='verify' id='verify' data-msg-required="验证码"/> </p> <img src='__MODULE__/Login/verify' width='110' id="verify_refresh" onClick="this.src='__MODULE__/Login/verify/'+Math.random();" style='cursor:pointer;float: right;' /> </div> <div class="rember"> <label><span class="s1"><input type="checkbox" class="input_check" id="check1" name="is_remember" value="1"><label for="check1"></label> 记住密码</span></label> </div> <div><input type="submit" value="登录" class="submit_btn"/></div> </form> </div>
/** * 记住密码/清空密码 * * @param $username * @param $pwd * @param $name */ public function SeTpassword($username, $pwd , $name, $type){ if($type == 1) { $data = array( 'jz_username' => $username, 'jz_pwd' => $pwd ); $key = base64_encode(json_encode($data)); setcookie($name, $key, time() + 3600 * 24 * 7, '/', '', '', true); }else{ setcookie($name,'' , time() - 3600 * 24 * 30, '/', '', '', true); } } /** * 得到保存的密码 * @param $name * @return mixed */ public function GetPassword($name){ $info = array(); if(!isset($_COOKIE[$name])){ $data['errorCode'] = 1; }else{ if($_COOKIE[$name] == ''){ $data['errorCode'] = 1; }else{ $key = json_decode(base64_decode($_COOKIE[$name], true),true); if(!is_array($key)){ $data['errorCode'] = 1; }else{ $data['errorCode'] = 0; $info['jz_username'] = $key['jz_username']; $info['jz_pwd'] = $key['jz_pwd']; $info['jz_type'] = 1; } } } if($data['errorCode'] == 1){ $info['jz_username'] = ''; $info['jz_pwd'] = ''; $info['jz_type'] = 0; } return $info; }
php资料