首页 \ 问答 \ PHP验证码使用纯文本(PHP captcha using plain text)

PHP验证码使用纯文本(PHP captcha using plain text)

这是我第一次在这里发帖,因为这也是我第一次决定从头开始为自己建立一个网站。 我正在创建一个带有基本验证码脚本的联系页面。 由于您可能认为疯狂的原因,我想将验证码显示为文本。 我决定反对png,因为(反)别名是非常糟糕的透明背景,我不认为我的网站会引起太多不必要的注意。

这是我的captcha.php

<?php 

session_start();

$characters_on_image = 4;

$possible_letters = '0123456789';

$code = '';

$i = 0;
while ($i < $characters_on_image) { 
$code .= substr($possible_letters, mt_rand(0, strlen($possible_letters)-1), 1);
$i++;
}

echo $code;


header('Content-Type: text/plain');

$_SESSION['code'] = $code;
?>

我遇到的问题是,如果我使用<?php print $_SESSION['code']; ?> <?php print $_SESSION['code']; ?>它会打印上一个代码。 我的编程非常复杂,我想知道是否有办法在<label>标签中显示当前生成的代码?


It's my first time posting here as it's also the first time I've decided to build a site from scratch for myself. I'm creating a contact page with a basic captcha script. For reasons you might think are crazy, I want to display the captcha as text. I decided against png as the (anti)aliasing was pretty bad with a transparent background and I don't think my site is going to cause too much unwanted attention yet.

Here is my captcha.php

<?php 

session_start();

$characters_on_image = 4;

$possible_letters = '0123456789';

$code = '';

$i = 0;
while ($i < $characters_on_image) { 
$code .= substr($possible_letters, mt_rand(0, strlen($possible_letters)-1), 1);
$i++;
}

echo $code;


header('Content-Type: text/plain');

$_SESSION['code'] = $code;
?>

The problem I'm having is that if I use <?php print $_SESSION['code']; ?> it will print the previous code. My programming is pretty ropey and I was wondering if there is a way to show the current generated code in a <label> tag?


原文:https://stackoverflow.com/questions/10147721
更新时间:2022-02-27 16:02

最满意答案

将任何属性传播到所有UI对象的最快和最干净的方法是使用findobj

set(findobj('Type','uicontrol'), 'BusyAction','cancel', 'Interruptible','off');

The fastest and cleanest way to propagate any property to all UI objects is with findobj:

set(findobj('Type','uicontrol'), 'BusyAction','cancel', 'Interruptible','off');

相关问答

更多
  • 是的,这是可能的,而且非常简单。 您可以直接在按钮回调中调用.m文件,并像在任何其他脚本中一样获取结果。 让我们考虑一个简单的例子,你可以从回调中调用函数A 假设函数A输出2个参数, out1和out2 。 在函数A的.m文件中,函数定义如下(输入参数当然可以是任何东西): function [ou1,out2] = A(Input arguments) %// code here end 然后在GUI中的按钮回调中,使用此语法检索函数A的输出并使用它们: [B,C] = A(Input argume ...
  • 我建议添加一个包装函数,它包装所有原始的UIControl回调函数。 包装函数执行以下操作: 锁定(禁用)所有GUI UIControl对象。 执行原始回调函数。 在原始回调返回后启用所有GUI UIControl。 您还可以在原始回调之前启动计时器,并在回调返回时停止计时器(计时器可以使用内置于主GUI的图像模拟等待条[小轴内的图像])。 示例(假设GUI是使用guide工具创建的): % --- Executes just before untitled1 is made visible. functi ...
  • 我不会再次调用screen3() 。 您可以清除编辑字段,显示成功消息并让他再次进入。 将您的数据评估(您当前在edit2_Callback具有的edit2_Callback )移动到“下一步”按钮,然后在获得数据后, set(handles.edit1, 'String', ''); set(handles.edit2, 'String', ''); set(handles.text1, 'String', sprintf('Connection (%d, %d) was added.',i,j)); ...
  • 你在没有任何输入参数的情况下调用add。 在GUI之间传递数据的一种方法是将handles.a和handles.b作为输入参数传递给子GUI,然后将它们用作添加的输入参数。 在子GUI打开函数( subGUI_OpeningFCN )的顶部添加以下行: handles.a = varargin{1}; handles.b = varargin{2}; 将子GUI功能pushbutton1_Callback更改为: main_gui('addition', handles.a, handles.b); 在 ...
  • 匿名函数是函数句柄的子集,允许您完全定义函数内联,而不是执行其他地方存在的函数的函数句柄。 匿名函数的语法是af = @(arglist)anonymous_function ,它在功能上与: function af(arglist) anonymous_function end 这意味着你的PostSet回调在功能上等同于: function PostSet(o,e) onChangedF(handles, e.AffectedObject) end 这满足了MATLAB的回调定义要 ...
  • 你遇到的问题是调用Histogram并将其传递给str : Histogram(str) 但是你没有定义Histogram以期望输入: function Histogram 你需要的是这样的: function Histogram(str) % do something with str You're problem is that call Histogram and pass it str: Histogram(str) But you don't define Histogram to ex ...
  • 您可以使用句柄结构保存要在不同函数之间使用的变量。 例如,如果我想将数组A传递给另一个函数: % --- Executes on button press in push_button1. function push_button1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future versi ...
  • 将任何属性传播到所有UI对象的最快和最干净的方法是使用findobj : set(findobj('Type','uicontrol'), 'BusyAction','cancel', 'Interruptible','off'); The fastest and cleanest way to propagate any property to all UI objects is with findobj: set(findobj('Type','uicontrol'), 'BusyAction','c ...
  • 正如您在生成的代码中看到的那样: % --- Executes on button press in FFT. function FFT_Callback(hObject, eventdata, handles) % hObject handle to FFT (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles a ...
  • 要使用句柄,我使用 h = guihandles(figure_handle); 这将在结构h中存储与* figure_handle *相关联的所有句柄。 然后,您可以使用get()函数访问所需句柄的各种属性。 h的字段是每个句柄的属性“Tag”。 注意:如果您的uipushbutton的'标签'无效或为空,它将不会显示在h中 。 当一次只使用一个GUI时,通常可以编写guihandles(gcf)而不是显式调用数字句柄,但这可能不适用于您的情况。 除此之外,我不能完全告诉你要用你的第二个GUI做什么。 ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)