当前位置:网站首页>个人博克系统登录点击图形验证码的集成与实现
个人博克系统登录点击图形验证码的集成与实现
2022-07-28 17:47:00 【wyqgg123】
概述:
关于登录验证码我一直没有实现,今天我再网上看验证码时,看到了一个基于PHP的jQuery中文点击验证码插件,我就试着将该插件引入,发现该插件非常简单易用,下面就是实现过程
1、下载地址
gitee:https://gitee.com/hooray/clicaptcha.git
2、引用
<link rel="stylesheet" href="/clicaptcha/css/captcha.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/js-cookie/2.2.1/js.cookie.min.js"></script>
<script src="/clicaptcha/clicaptcha.js"></script>
<!--图形验证码-->
<input type="hidden" id="clicaptcha-submit-info" name="clicaptcha-submit-info">
<script> $('#clicaptcha-submit-info').clicaptcha({
src: '/clicaptcha/clicaptcha.php', success_tip: '验证成功!', error_tip: '未点中正确区域,请重试!', callback: function(){
//... } }); </script>
3、集成到项目中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Login</title>
<link rel="stylesheet" href="/css/layui/css/layui.css">
<script src="/css/layui/layui.js"></script>
<link rel="stylesheet" href="/clicaptcha/css/captcha.css">
<link rel="stylesheet" href="/css/main.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
</head>
<body style="background-color:#5FB878">
<div>
<h1 style="color: #fafafa;text-align: center;line-height: 80px">wyq博客系统后台登录</h1>
</div>
<div style="width: 30%;height: 40%;position: absolute;left:35%;top:30%;background-color:#FAFAFA">
<div style="width: 100%;height: 20%;background-color: #009688;">
<h1 style="color: #fafafa;text-align: center;line-height: 80px">管理员登录</h1>
</div>
<div style="padding: 40px;">
<form class="layui-form" action="/admin/doLogin" method="post">
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
<div class="layui-input-block">
<input type="text" id="username" name="username" placeholder="请输入用户名" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-block">
<input type="password" id="password" name="password" placeholder="请输入密码" class="layui-input">
</div>
</div>
<!--图片验证码隐藏域-->
<input type="hidden" id="clicaptcha-submit-info" name="clicaptcha-submit-info">
<button id="submit" type="button" class="layui-btn" style="margin-left: 80px;margin-top: 20px">登录</button>
<a type="button" href="/login/regist" style="margin-left: 250px;margin-top: 20px" class="layui-btn">注册</a>
</form>
<a href="/login/forget" style="margin-top: 20px;">忘记密码?</a>
</div>
</div>
</body>
</html>
<script src="https://cdn.bootcss.com/js-cookie/2.2.1/js.cookie.min.js"></script>
<script src="/clicaptcha/clicaptcha.js"></script>
<script> //点击登录时 $("#submit").click(function () {
//验证你点击的字符 $('#clicaptcha-submit-info').clicaptcha({
src: '/clicaptcha/clicaptcha.php', success_tip: '验证成功!', error_tip: '未点中正确区域,请重试!', //成功调用函数 callback: function(res){
var data = {
'username': $('#username').val(), 'password': $('#password').val(), 'clicaptcha-submit-info':$('#clicaptcha-submit-info').val() }; $.ajax({
'url': '/login/doLogin', 'type':'post', 'dataType':'json', 'data':data, 'success':function (msg) {
if (msg.code == 200){
layui.use('layer', function() {
var layer = layui.layer; layer.msg('登录成功'); }) setTimeout(function(){
window.location.replace("/user/index") },800); }else if(msg.code == 400){
layui.use('layer', function() {
var layer = layui.layer; layer.msg(msg.msg); }) } } } ) } }); }) </script>
页面展示:
边栏推荐
- The United States will provide $25billion in subsidies to encourage chip manufacturers such as Intel to move back to production lines
- MySQL8 Status Variables: Internal Temporary Tables and Files
- ES6 new - arrow function
- Convertible bond concept table x notation gives you a convenient and fast experience!
- 【经验之谈】关于维修电子设备的几点建议和经验
- Rust Getting Started Guide (rustup, cargo)
- WPF implements MessageBox message prompt box with mask
- MySQL 8 creates master-slave replication based on Clone
- Nips18 (AD) - unsupervised anomaly detection using geometric transformations using geometric augmentation
- Swing事件处理的过程是怎样的?
猜你喜欢

英文翻译意大利语-批量英文翻译意大利语工具免费

JS preventDefault() 键盘输入限制 onmousewheel stopPropagation停止事件传播

【微信小程序开发】页面导航与传参

架构基本概念和架构本质

Using Baidu easydl to realize chef hat recognition of bright kitchen and stove

WPF 实现带蒙版的 MessageBox 消息提示框

navicate修改数据库名的方式

微信公众号授权登录后报redirect_uri参数错误的问题

Transformer for anomaly detection - instra "painting transformer for anomaly detection"

This customized keyboard turns me on~
随机推荐
为研发高端光刻胶,晶瑞股份斥资7500万元购买SK海力士的ASML光刻机
基于C语言的信息管理系统和小游戏
企业级分布式爬虫框架入门
redis 主从架构(sizeof函数怎么计算)
After reading the thesis for three years, I learned to read the abstract today
Left alignment function of Lua language (handwriting)
使用SaltStack自动化部署Zabbix
lua语言的左对齐函数(手写)
Update of objects in ES6
Sudo rosdep init error: cannot download default
Germany and Portugal have announced that they will not disable Huawei 5g equipment, but Germany will set strict restrictions!
Swing事件处理的过程是怎样的?
Test Development Notes
德国、葡萄牙均宣布不会禁用华为5G设备,但德国会设定严格限制条件!
Quickly install torch spark, torch geometric and other packages in moment pool cloud
NDK series (5): from introduction to practice, JNI explodes the liver and explains everything in detail!
基于QTGUI图像界面的空战游戏设计
调用整数或字符数组函数里的参数应该传入啥
Report redirect after authorized login on wechat official account_ The problem of wrong URI parameters
Redis master-slave architecture (how to calculate sizeof function)