使用jQuery和PHP检查验证码(Checking captcha with jQuery and PHP)
我正在编写动态联系表格。 代码如下所示:
jQuery的:$.ajax({ type: "POST", url: "sendmail.php", data: {email: email, message: message, captcha: captcha} }) .done(function( result ) { alert(result); })
PHP:
<?php session_start(); $email = $_POST['email']; $message = $_POST['message']; $captcha = $_POST['captcha']; if(isset($_POST["captcha"])&&$_POST["captcha"]!=""&&strtoupper($_SESSION["captcha_code"])==strtoupper($_POST["captcha"])) { @mail('mymail@gmail.com', 'Subject', $message, 'From:' . email); echo "Message successfully sent."; } else { // change opacity of #error div } ?>
问题是如果输入了错误的验证码,如何更改隐藏div的不透明度? 在这种情况下,我需要在PHP脚本或其他地方插入此代码:
$('#error').css({opacity:'1'});
请记住,我不能用echo注入代码,因为我使用alert来提供从PHP脚本返回的信息。
I'm coding dynamic contact form. The code look like this:
jQuery:$.ajax({ type: "POST", url: "sendmail.php", data: {email: email, message: message, captcha: captcha} }) .done(function( result ) { alert(result); })
PHP:
<?php session_start(); $email = $_POST['email']; $message = $_POST['message']; $captcha = $_POST['captcha']; if(isset($_POST["captcha"])&&$_POST["captcha"]!=""&&strtoupper($_SESSION["captcha_code"])==strtoupper($_POST["captcha"])) { @mail('mymail@gmail.com', 'Subject', $message, 'From:' . email); echo "Message successfully sent."; } else { // change opacity of #error div } ?>
The problem is how to change opacity of hidden div if wrong captcha code has been entered? In that case I need to insert this code insid PHP script or somewhere else:
$('#error').css({opacity:'1'});
Remember, that I cannot inject code with echo, because I use alert for information coming back from PHP script.
原文:https://stackoverflow.com/questions/17845398
满意答案
将字段分隔符(-F)更改为选项卡:
$ awk -F$'\t*' '{gsub(/ /,"_",$1); print $1,$2}' test2.in Joe_Jonas 8 Cersei_Lann 4 Bo_Tox 6 Mis_Ter_Yo 7
编辑:在第一列使用
gsub
用下划线替换空格。Change the field separator (-F) to tab(s):
$ awk -F$'\t*' '{gsub(/ /,"_",$1); print $1,$2}' test2.in Joe_Jonas 8 Cersei_Lann 4 Bo_Tox 6 Mis_Ter_Yo 7
EDIT: Use
gsub
on first column to replace space with underscore.
相关问答
更多AWK使用多个空格作为分隔符(AWK to use multiple spaces as delimiter)
使用空格作为具有剪切命令的分隔符(use space as a delimiter with cut command)
拆分制表符分隔的空格列(Split tab delimited column with space)
awk命令:如何告诉它区分空格和制表符分隔符(awk command: how to tell it to distinguish between space and tab delimiter)
读取行时,awk $行有多个分隔符(While read line, awk $line with multiple delimiters)
awk:通过特定的分隔符删除字符串(awk: remove strings by specific delimiter)
在mule esb中使用DataMapper使用自定义分隔符(空格或制表符)编写CSV文件(Writing CSV file using custom Delimiter (space or tab) using DataMapper in mule esb)
如何使用Netezza NZSQL中的制表符分隔符输出文件(How to output a file using tab delimiter in Netezza NZSQL)
从Google文档电子表格粘贴时获取不一致的制表符分隔符宽度(Getting inconsistent tab delimiter width when pasting from Google docs spreadsheet)
awk如何将记录分隔符设置为多个连续的空行或行仅包含空格和/或制表符?(awk how to set record separator as multiple consecutive empty lines or lines only include space and/or tab characters?)
相关文章
更多jquery 问题
Jquery EasyUI系列教程1
jQuery表格插件jqGrid(jquery.jqGrid.js)
jQuery实战经典视频教程
《自学it网-PHP公益培训-YY直播中[24小时供源]-(4月9日更新)-PHP项目实战 mysql smarty thinkphp javascript ajax jquery linux lamp》[WMV]
PHP简介
jQuery中$与$()的区别?
php匹配问题
《后盾网盾友 JQuery 视频教程 》(JQuery )更新至30课[WMV]
用jquery validate封装自己的验证库
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!