- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用这个脚本:https://github.com/claviska/simple-php-captcha
在 php 中制作验证码。
我有这个代码:
session_start();
include_once 'simple-php-captcha.php';
$_SESSION = array();
$_SESSION['captcha'] = simple_php_captcha();
$code = $_SESSION['captcha']['code'];
if (isset($_POST['username'])&&isset($_POST['password'])) {
if (!empty($_POST['username']) && !empty($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if (isset($_POST['captcha'])&&!empty($_POST['captcha'])) {
$captcha = $_POST['captcha'];
if ($captcha == $code) {
echo "Login";
} else {
$errors[] = "Capcha is Not True.";
}
} else {
$errors[] = "Enter capcha.";
}
} else {
$errors[] = "Enter all.";
}
}
和 HTML 表单:
<form accept="" method="POST">
username: <input type="text" name="username">
password: <input type="password" name="password">
captcha: <input type="text" name="captcha">
<img src="<?php echo $_SESSION['captcha']['image_src']; ?>">
<input type="submit" class="Button" value="submit">
</form>
但是
问题是每次我输入验证码并提交表单时,都会生成较新的验证码并且表单总是返回 NOT TRUE CAPTCHA pm。
例如我打开页面,例如验证码是:52111,(我输入正确)然后我提交,然后我看到验证码不正确的错误,因为生成的较新的验证码是另一个像:48852。
我的意思是每次页面生成一个更新的页面,我该如何解决这个问题??
最佳答案
在检查表单之前,您应该保存旧的验证码值:
session_start();
if (!isset($_SESSION['captcha']) {
$_SESSION['captcha'] = simple_php_captcha();
}
$code = $_SESSION['captcha']['code'];
include_once 'simple-php-captcha.php';
if (isset($_POST['username'])&&isset($_POST['password'])) {
if (!empty($_POST['username']) && !empty($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if (isset($_POST['captcha'])&&!empty($_POST['captcha'])) {
$captcha = $_POST['captcha'];
if ($captcha == $code) {
echo "Login";
} else {
$errors[] = "Capcha is Not True.";
}
unlink($_SESSION['captcha'])
} else {
$errors[] = "Enter capcha.";
}
} else {
$errors[] = "Enter all.";
}
}
关于php Captcha 正在返回旧值并检查旧值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25663454/
在 CloudFlare Web Application Firewall您可以根据 IP 地址、国家/地区名称或 ASN 阻止、白名单、CAPTCHA 或 JavaScript Challenge
有没有人能够在不给访问者带来负担(例如 CAPTCHA)且不使用集中式垃圾邮件报告系统(例如 Akismet)的情况下成功阻止其网站上的垃圾邮件 我找到了 this & it looks promis
如何在本地网络上的测试服务器中使用Google的reCAPTCHA? 根据documentation: By default, all keys work on "localhost" (or "12
你好,我看到 facebook 在使用 recaptcha,但在他们的注册页面中,他们可以显示一个单词而不是两个,然后我注意到 repcatcha 只验证第一个单词,第二个单词充当虚拟词,问题是我们能
在所有可用的CAPTCHA形式中,哪一种是“最不易破解的”,同时又保持了人类可读性? 最佳答案 我同意托马斯的观点。验证码即将出局。但是,如果必须使用它,reCAPTCHA是使用简单API的不错的提供
检测reCaptcha v2是否未加载的最佳方法是什么?我想提醒用户何时需要使用验证码才能继续,但是无法加载。 最佳答案 您可以在请求验证码时传递回调函数 将此添加到URL: ?onload=myfu
我在网站的表单提交中使用以下安全性(不可见验证码)以防止自动提交: 生成数字x上带有固定盐的md5结果并渲染它在表单内作为隐藏字段 生成 2 个隐藏字段 a 和 b,其中 a + b = x,a 和
我在这里寻找灵感。我需要对我的网站采用某种人工验证,但目前最常见的方法(要求用户将他们在图像中看到的字母和数字输入到文本输入框中)似乎有点垃圾 - 我发现有时很难弄清楚字母和数字是什么。 一定有更好的
复选框是否提供了在网站上使用验证码的替代方法?我想我需要使用验证码进行用户注册。相反,如果我为“通过单击此处我同意......”之类的条款添加一个复选框,可以解决机器人问题吗?或者除了复选框之外还需要
我刚刚在 github 上看到了这个天才脚本: https://github.com/jsavoie/proof-of-work-login 我的问题是:为什么 POW 登录在 2018 年还不是世界
我正在尝试使用OpenCV和pytesseract解决一些简单的验证码。验证码示例包括: 我试图用一些过滤器去除嘈杂的点: import cv2 import numpy as np import p
我知道这不是一个真正的编程问题,但我不知道在哪里问。 我应该在注册表单中使用验证码吗? Facebook、twitter、foursquare、gowalla 等...不要使用其中之一(或不可见的)。
我想阻止垃圾邮件发送者使用我的网站。但我觉得验证码很烦人。我所说的不仅仅是“输入文本”类型,而是任何需要用户浪费时间来证明自己是人类的东西。 我在这里能做什么? 最佳答案 要求 Javascript
这个问题已经有答案了: 已关闭14 年前。 破解验证码的方法、算法有哪些? 最佳答案 Security Now 播客有一集是关于这个的。文字记录链接如下。 http://www.grc.com/sn/
我的网站使用 6 位数字的验证码,但是如果攻击者尝试所有组合,他很可能会成功提交表格分数的次数。(理论上是 1/百万,自从我使用随机数生成器以来,在实践中更多不是真正随机的)。 反正我有办法进一步阻止
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post的一个问题。
我有一个用户填写的网络表单,并将信息发送到服务器并存储在数据库中。我担心机器人可能只是填写表格,我最终会得到一个充满无用记录的数据库。如何防止机器人填写我的表格?我在想可能类似于 Stackoverf
reCAPTCHA的先前版本提供了制作可以在任何域上使用的全局 key 的选项。现在,在版本2中,该选项消失了,并且reCAPTCHA网站声称“V2 API中不支持全局 key ”。 我正在使用大量域
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 5年前关闭。 Improve thi
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我是一名优秀的程序员,十分优秀!