社区
基础编程
帖子详情
php验证码 怎么弄
libero2014
2012-02-12 09:23:24
跪求高手 加我QQ779846529
...全文
260
12
打赏
收藏
php验证码 怎么弄
跪求高手 加我QQ779846529
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
12 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
libero2014
2012-02-16
打赏
举报
回复
代码如上 求帮忙啊
lession
2012-02-16
打赏
举报
回复
这里有代码,我就是这样做的
http://www.lession.net/blog/473.html
libero2014
2012-02-15
打赏
举报
回复
<?php require_once('Connections/conn.php'); ?>
<?php session_start();?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO user_zc (username, pass, phonenumber, realname, sex) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['pass'], "text"),
GetSQLValueString($_POST['phonenumber'], "int"),
GetSQLValueString($_POST['realname'], "text"),
GetSQLValueString($_POST['select'], "text"));
if ($_POST['yzm'] !== $_SESSION["vocode"]) {
header("location: ". "user_zcsb.php" );
}
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
$insertGoTo = "user_zccg.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户注册</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
<table width="240" border="0">
<tr>
<td height="54" colspan="2">会员账号注册</td>
</tr>
<tr>
<td width="44" height="90">*用户名</td>
<td width="186"><input name="username" type="text" id="username" maxlength="12" /></td>
</tr>
<tr>
<td height="87">*密码</td>
<td><label>
<input name="pass" type="password" id="pass" />
</label></td>
</tr>
<tr>
<td height="39">*性别</td>
<td><label>
<select name="select" id="select">
<option value="男">男</option>
<option value="女">女</option>
</select>
</label></td>
</tr>
<tr>
<td height="75">*手机</td>
<td><label>
<input name="phonenumber" type="text" id="phonenumber" />
</label></td>
</tr>
<tr>
<td height="96">*真实姓名</td>
<td><label>
<input name="realname" type="text" id="realname" />
</label></td>
</tr>
<tr>
<td height="68" colspan="2"><label>*验证码
<input name='yzm' type='text' id="yzm" size='5' />
<img src='vcode/vcode.php' alt="" border='0' align='absmiddle' /><br />
</label></td>
</tr>
<tr>
<td height="130" colspan="2"><input type="submit" name="Submit" value="提交" />
<input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
======================================================================
怎样通过验证码,才能提交内容,,可是每次验证码输错了,,内容却被提交了
码无边
2012-02-14
打赏
举报
回复
贴出你的疑问,不要说,不知道。
xb12369
2012-02-14
打赏
举报
回复
不会验证码总会百度吧???
直接百度一下!!!
yixi_xiangyi
2012-02-13
打赏
举报
回复
1、假如你的是login.php页面:在此页面下,
<?php
include ("conn.php"); //这个是连接Mysql的
session_start();
echo $_SESSION[check_pic];
if ($_POST) {
$code=$_POST[code];
if($code!=$_SESSION[check_pic])
echo "<script>alert('验证码有误!');location.href='login.php';</script>";
}
?>
<form id="form1" name="form1" method="post" action="" >
<input name="code" type="text" id="code" size="8" /> <img src="inc/vCode.php" alt="验证码" width="55" height="30" align="absmiddle" style="cursor:pointer" onclick="javascript:this.src='inc/vCode.php?tm='+Math.random()" />
<input type="submit" name="button" id="button" value="提交" />
</form>
2、src='inc/vCode.php?tm='+Math.random()中的inc/vCode.php,是指当前目录下的inc文件夹下,要放个vCode.php,你新建个vCode.php,代码如下,你粘贴即可:
<?php
/*
* 放一个font.ttc字体到目录下
$num 字符个数
$size 字符大小
颜色随机
*/
// vCode ********
function vCode($num = 4, $size = 20, $width = 0, $height = 0) {
session_start();
!$width && $width = $num * $size * 4 / 5 + 5;
!$height && $height = $size +10;
// 去掉了 0 1 O l 等
$str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVW";
$code = '';
for ($i = 0; $i < $num; $i++) {
$code .= $str[mt_rand(0, strlen($str) - 1)];
}
$_SESSION[check_pic]=$code;
// 画图像
$im = imagecreatetruecolor($width, $height);
// 定义要用到的颜色
$back_color = imagecolorallocate($im, 235, 236, 237);
$boer_color = imagecolorallocate($im, 118, 151, 199);
$text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
// 画背景
imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
// 画边框
imagerectangle($im, 0, 0, $width -1, $height -1, $boer_color);
// 画干扰线
for ($i = 0; $i < 5; $i++) {
$font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagearc($im, mt_rand(- $width, $width), mt_rand(- $height, $height), mt_rand(30, $width * 2), mt_rand(20, $height * 2), mt_rand(0, 360), mt_rand(0, 360), $font_color);
}
// 画干扰点
for ($i = 0; $i < 50; $i++) {
$font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $font_color);
}
// 画验证码
imagefttext($im, $size, 0, 5, $size +3, $text_color, 'simkai.ttf', $code);
header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
}
vCode(4, 20);
// 4个字符,大小为20
//调用方法:<img src="inc/vcode.php" />
?>
cezanneluo
2012-02-13
打赏
举报
回复
随机选取数字或字母再以图片形式显示出来就行啦
libero2014
2012-02-13
打赏
举报
回复
能把你QQ给我 吗?这样很不方便。[Quote=引用 6 楼 phpnewnew 的回复:]
引用 5 楼 zifang20 的回复:
引用 3 楼 cezanneluo 的回复:
随机选取数字或字母再以图片形式显示出来就行啦
这个 会 就是一直判断验证码的代码 总是有问题。
那你就把你的代码给贴出来 别人才好知道是哪有问题,这么说别人怎么判断?
[/Quote]
黄袍披身
2012-02-13
打赏
举报
回复
[Quote=引用 5 楼 zifang20 的回复:]
引用 3 楼 cezanneluo 的回复:
随机选取数字或字母再以图片形式显示出来就行啦
这个 会 就是一直判断验证码的代码 总是有问题。
[/Quote]
那你就把你的代码给贴出来 别人才好知道是哪有问题,这么说别人怎么判断?
libero2014
2012-02-13
打赏
举报
回复
[Quote=引用 3 楼 cezanneluo 的回复:]
随机选取数字或字母再以图片形式显示出来就行啦
[/Quote]这个 会 就是一直判断验证码的代码 总是有问题。
libero2014
2012-02-12
打赏
举报
回复
还是 不会 能否帮帮忙 很急
黄袍披身
2012-02-12
打赏
举报
回复
有什么怎么弄的嘛?网上很多现成的代码复制一个就能用了。
WordPress插件:关注微信公众号获得
验证码
涨粉插件
在WordPress后台,我们需要下载插件,而后通过上传的方式启用这款插件。...本插件非常小巧,只有一个wechat-fans.
php
文件,下载插件解压后,只需把wechat-fans.
php
放到/wp-content/plugins/wechat-fans.
php
即可。
PHP
学生成绩管理系统源码.zip
虽然是传统节目了,但我还是想弄点新花样。在开发的过程中还是边写边查地面向谷歌编程...... 在功能设计与 js 的编写耗费了大量的时间,但还是写得挺粗糙的,继承方式很乱,也有很多肉眼可见的飞线 \doge。 使用方式...
易语言-易语言执行
php
代码
至于为什么想到这么干,是因为看到了作业区要用易语言创
验证码
,要求说能显示就行了用什么方法都可以,刚好最近在研究
php
的
验证码
,就想着能不能弄个简单的本地环境,就把手上的
php
7精简了一下,一试还真的可以,ext...
帝国cms增加了金刚模式,登录发布文章有难度 免登录发布模块配合火车采集器,完美解决你遇到的问题 1.必备工具: 1.火车采
全局变量是一个
验证码
,接口文件EcmsLogin.
php
开头的地方,可以自己进行修改,也可以自己进行设置;该接口文件放置在网站根目录/e/admin/文件夹下。该配置模块在配置时,网址只需要写:http://域名.com 2、获取分类 ...
这是我用Vue写的一个微信第三方公众号管理平台.zip
还有一开始我从单页项目弄成多个入口,最后在实际发现应该单页应用。这个项目的演讲地址不能正常演讲了,原因是操蛋的腾讯服务器没有自动快照,我恢复到7月5号快照,下面有些东西不在了。所以不打算修复了!新的演示...
基础编程
21,890
社区成员
140,347
社区内容
发帖
与我相关
我的任务
基础编程
从PHP安装配置,PHP入门,PHP基础到PHP应用
复制链接
扫一扫
分享
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章