码迷,mamicode.com
首页 > 其他好文 > 详细

tp5验证码的使用

时间:2018-01-30 21:14:48      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:UI   orb   account   parse   word   $_server   size   跳转   exe   

<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();
}
}
}

tp5验证码的使用

标签:UI   orb   account   parse   word   $_server   size   跳转   exe   

原文地址:https://www.cnblogs.com/wszz/p/8386984.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!