公共管理之重置密码
公共的模板
<!-- 模板 --> <script id="render-tpl" type="text/html"><div class="panel-body"><div class="table-responsive col-lg-10"><form class="form-horizontal addForm" method="post" action="/admin.php/Public/resetPassword" name="form1" id="reset_password_sub_form"><div class="form-group col-lg-12"><label class="control-label col-lg-3 text-right">密碼:</label><input class="form-control-erbi col-lg-5" type="password" id="password" name="password" placeholder='密碼' /><span class="col-lg-4 text-left erbi-form-right">請填寫密碼</span></div><div class="form-group col-lg-12"><label class="control-label col-lg-3 text-right">確認密碼:</label><input class="form-control-erbi col-lg-5" type="password" id="re_password" name="re_password" placeholder='請再輸入一次密碼' /><span class="col-lg-4 text-left erbi-form-right">請再輸入一次密碼</span></div><div class="form-group"><div class="col-lg-2 col-lg-offset-3"><button type="button" class="btn btn-primary col-lg-8" id="reset_password_sub_btn">提交</button></div><div class="clear"></div></div></form></div><!-- /.table-responsive --></div></script>公共的js
<script>/*** 重置密碼*/$("#resetPassword").on('click', function () {let html = template('render-tpl', {});layer.open({title: '重置密碼',type: 1,skin: 'layui-layer-rim', //加上邊框area: ['800px', '400px'], //寬高content: html});});$(document).on('click','#reset_password_sub_btn',function(){$("#reset_password_sub_form").ajaxForm({dataType: "json",success : function(obj){if(obj.errno == 0){layer.msg('已保存');setTimeout(function() {layer.closeAll();window.location.reload();},1000);}else{layer.msg(obj.errdesc);}return false;}});if(!dealText('#password','請填寫密碼')) {return;}if(!dealText('#re_password','請填寫確認密碼')) {return;}$("#reset_password_sub_form").submit();return false;});</script>公共的引入
<!-- art --> <script src="/src/art-template.js"></script><!-- Layer 彈出層 --> <script src="/plugin/layer/layer.js"></script><!-- Lay日期 --> <script src="/plugin/laydate/laydate.js"></script><script src="/erbi/js/bootstrap.min.js"></script> <script type="text/javascript" src="/plugin/ajaxUpload/ajaxfileupload.js"></script> <script type="text/javascript" src="/plugin/jquery.form.js"></script> <script type="text/javascript" src="/admin/js/common.js"></script>公共的后臺方法
// 重置密碼 public function resetPassword() {$json = new Json();if (!$password = trim($_POST['password'])) {$json->setErr(10001, '請輸入密碼');$json->Send();}$re_password = trim($_POST['re_password']);if ($password !== $re_password) {$json->setErr(10001, '確認密碼與密碼不一致');$json->Send();}$admin_uid = session('_admin_user_id');$data['password'] = md5($password);$admin_user = model('admin_user');$save_flag = $admin_user->where(['id' => $admin_uid])->update($data);if ($save_flag === false){$json->setErr('10223','操作失敗');$json->Send();}$json->setErr('0','操作成功');$json->Send(); }轉載于:https://www.cnblogs.com/jiqing9006/p/11158030.html
總結
- 上一篇: 39. Combination Sum
- 下一篇: JXCPC 试题册