zoukankan      html  css  js  c++  java
  • tp5验证码的使用

    <div><img id="verify_img" src="{:captcha_src()}" alt="验证码" onclick="refreshVerify()"></div>

    <a href="javascript:refreshVerify()"><span id="sx" style="cursor:pointer;font-size:14px;color:#eee;">看不清楚,<br>换一张</span></a>

    <script type="text/javascript">
    function refreshVerify() {
    var ts = Date.parse(new Date())/1000;
    var img = document.getElementById('verify_img');
    img.src = "/captcha?id="+ts;
    }

    </script>

    public function login()
    {
    if(empty(input('param.'))){
    return $this->fetch();
    }else{
    $verifyCode = input('post.verifyCode');
    if(captcha_check($verifyCode)){
    $uid = input('post.uid');
    $pwd = input('post.pwd');
    if($uid!="" && $pwd!=""){
    $admin = db("Admin");
    $admin_forbid = $admin->where("admin_account='$uid'")->value('admin_forbid');
    $admin_password = $admin->where("admin_account='$uid'")->value('admin_password');
    if($admin_forbid=='是'){
    echo "<script>alert('该用户已被禁用,请联系管理员')</script>";
    return $this->fetch();
    }elseif($pwd==$admin_password){
    session('admin_account', $uid); // 跳转页面之前将$uid存入session
    $ip=$_SERVER["REMOTE_ADDR"];
    $admin->execute("update admin set admin_loginnum=admin_loginnum+1,admin_loginip='$ip',admin_logintime=now() where admin_account='$uid'");
    $this->redirect('index/index');
    }else{
    echo "<script>alert('登录失败')</script>";
    return $this->fetch();
    }
    }else{
    echo "<script>alert('用户名或者密码不能为空!')</script>";
    return $this->fetch();
    }
    }else{
    echo "<script>alert('验证码不正确!')</script>";
    return $this->fetch();
    }
    }
    }

    A buddhist programmer.
  • 相关阅读:
    js——DOM层次节点(一)
    js——客户端检测
    js——navigator,screen,history对象(BOM 3)
    【bzoj1096】[ZJOI2007]仓库建设
    【bzoj1010】[HNOI2008]玩具装箱toy
    【bzoj3566】 [SHOI2014]概率充电器
    【bzoj1013】[JSOI2008]球形空间产生器sphere
    【FJ省队训练&&NOIP夏令营】酱油&&滚粗记
    【bzoj3676】[Apio2014]回文串
    【bzoj1031】[JSOI2007]字符加密Cipher
  • 原文地址:https://www.cnblogs.com/wszz/p/8386984.html
Copyright © 2011-2022 走看看