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');

相关问答

更多

MATLAB:GUI按钮调用函数.m(MATLAB : GUI pushbutton call function .m)

是的,这是可能的,而且非常简单。 您可以直接在按钮回调中调用.m文件,并像在任何其他脚本中一样获取结果。 让我们考虑一个简单的例子,你可以从回调中调用函数A 假设函数A输出2个参数, out1和out2 。 在函数A的.m文件中,函数定义如下(输入参数当然可以是任何东西): function [ou1,out2] = A(Input arguments) %// code here end 然后在GUI中的按钮回调中,使用此语法检索函数A的输出并使用它们: [B,C] = A(Input a...

Matlab GUI回调开始和完成(Matlab GUI Callback Start and Completion)

我建议添加一个包装函数,它包装所有原始的UIControl回调函数。 包装函数执行以下操作: 锁定(禁用)所有GUI UIControl对象。 执行原始回调函数。 在原始回调返回后启用所有GUI UIControl。 您还可以在原始回调之前启动计时器,并在回调返回时停止计时器(计时器可以使用内置于主GUI的图像模拟等待条[小轴内的图像])。 示例(假设GUI是使用guide工具创建的): % --- Executes just before untitled1 is made visible. f...

matlab gui - 同样的gui屏幕(matlab gui - callling the same gui screen)

我不会再次调用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...

在MATLAB中在函数和回调之间传递数据(Passing data between functions and callbacks in MATLAB)

你在没有任何输入参数的情况下调用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...

Matlab匿名回调函数参数(Matlab anonymous callback function arguments)

匿名函数是函数句柄的子集,允许您完全定义函数内联,而不是执行其他地方存在的函数的函数句柄。 匿名函数的语法是af = @(arglist)anonymous_function ,它在功能上与: function af(arglist) anonymous_function end 这意味着你的PostSet回调在功能上等同于: function PostSet(o,e) onChangedF(handles, e.AffectedObject) end 这满足了MATLAB的...

在GUI matlab中运行函数(Running Functions in GUI 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 ...

Matlab Gui:如何在函数之间共享数据(Matlab Gui: how to share datas among functions)

您可以使用句柄结构保存要在不同函数之间使用的变量。 例如,如果我想将数组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 ...

避免在Matlab GUI中中断回调函数(Avoid interruption of callback functions in Matlab GUI)

将任何属性传播到所有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'), 'BusyActio...

matlab GUI回调(matlab GUI callback)

正如您在生成的代码中看到的那样: % --- 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 hand...

如何在Matlab中运行GUI之外的按钮回调?(How to run pushbutton callback outside of GUI in Matlab?)

要使用句柄,我使用 h = guihandles(figure_handle); 这将在结构h中存储与* figure_handle *相关联的所有句柄。 然后,您可以使用get()函数访问所需句柄的各种属性。 h的字段是每个句柄的属性“Tag”。 注意:如果您的uipushbutton的'标签'无效或为空,它将不会显示在h中 。 当一次只使用一个GUI时,通常可以编写guihandles(gcf)而不是显式调用数字句柄,但这可能不适用于您的情况。 除此之外,我不能完全告诉你要用你的第二个GUI...

相关文章

更多

简单验证码生成——Java版

验证码大家都知道,它的作用也不用我多说了吧。如果不太清楚请参见百度百科中的解释,一般验证码的生成就是随 ...

jsp 验证码刷新无反应 怎么回事

我用的生成验证码为 authcode.jsp 在 login.jsp 中使用: &lt;form ...

网络挖掘技术——text mining

一、中文分词:分词就是利用计算机识别出文本中词汇的过程。 1.典型应用:汉字处理:拼音输入法、手写识别 ...

java.text.DecimalFormat 的问题

各位好,我用java.text.DecimalFormat做一些格式化的工作,我的代码如下: Dec ...

my php & mysql FAQ

php中文字符串长度及定长截取问题使用str_len(&quot;中国&quot;) 结果为6,php ...

微信验证码

相信大家对微信都已经耳熟能详了。因为微信已经渐渐的融入我们生活的个个细节,回想当初刚开始玩儿微信的时候 ...

企业级搜索引擎Solr 第二章 Schema和文本分析(Schema and Text Analysis)[2]

文章转载自网易博客,原文地址:http://quweiprotoss.blog.163.com/blo ...

PHP简介

PHP PHP是运行在服务器端的脚本,可以运行在UNIX、LINUX、WINDOWS、Mac OS下 ...

请教怎么在CAS中添加验证码功能

公司项目要用到单点登录,根据linliangyi2007的CAS学习笔记初步掌握了CAS的使用,现在碰 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本