当前位置:首页 » 编程语言 » php显示验证码

php显示验证码

发布时间: 2023-03-22 23:42:13

A. php验证码显示问题 GD库函数imagecreatetruecolor使用不了 求救

Call
to
undefined

function
imagecreatetruecolor()
in
...
提示是:调用未定义的函数imagecreatetruecolor
你的
gd库
文件没有打开。
先打开你的php.
ini文件

查找
;extension=php_gd2.dll
,把前面的分号去掉,如果没有这句就加个(当然不要带分号,分号是注释掉的意思)然后保存退出。
如果没有gd2.
dll文件
的话,就到网上下载一个
重新启动apache服务器。

B. 为什么apache php无法显示验证码

验证码一般需要安装GD库来支持的,你可以看一下你的php.ini文件中是否开启了这一项,如果开启后重启Apache报错,那么还需要你安装。
Windows中是一个.dll文件,放到相应的目录就可以了。
Linux下安装可能对PHP的版本之类的有要求,最好别安装最新版本的GD库。

C. PHP 验证码不显示只有一个小红叉的解决方法

最近想自学PHP
,做了个验证码,但不知道怎么搞的,总出现一个如下图的小红叉,但验证码就是显示不出来,原因如下
未修改之前,出现如下错误;

(1)修改步骤如下,原因如下,原因是apache权限没开,

(2)点击打开php.int.,
搜索extension=php_gd2.dll
打开?去掉前面分号重启apache,就OK了
,万事大吉了。

希望各位朋友遇到这样的问题的时候,能给与帮助

D. php验证码问题


<?php
有关生成验证码的代码
?>
换成<img
src="yzm.php">
即可
yzm.php 上面
session_start()
前面的注释也要去掉,而且里面很多变量没有定义,如果PHP.INI开了错误提示,就是出错,提示变量不存在,就不会显示验证码。
login.php里面,空格
符应该是

不是
nbps
我写好了,放在我网站上了,演示效果网址:
http://dev.qkweb.net/php/yzm/login.php
下载代码的地址是:
http://dev.qkweb.net/php/yzm/20110701yzm.rar

E. 我的php代码中登陆界面加一个验证码,如何实现

php登陆页面+验证码的实现,参考如下:

1、首先新建一个php站点;

F. php中如何刷新验证码

我做的一个简单的登录界面有刷新验证码还有注册功能 希望对LZ有帮助
这个是登录界面 land.php
<?php
@include_once('global.php');
session_start();
$user = $_POST['username'];
$sql = sprintf("select * from `p_admin` where `username` = '%s'",$user);
//echo $sql;
$query = $db->query($sql);//调用golbal里面的$db类
$fetch = $db->fetch_array($query);
if($_POST['sccode']==$_SESSION['rand']){
$state = $fetch ? md5($_POST['password'].$extra)==$fetch['password']:FALSE;//是否登录成功 如果失败了返回为空echo $state没有结果
if(!$state)
echo"<script language=javascript>alert('用户名或密码错误');</script>";

else {
$_SESSION['id'] = $fetch['m_id'];
$_SESSION['shell'] = md5($fetch['username'].$fetch['password']);
$_SESSION['ontime'] = time();
//echo $_SESSION['id']."<br>";
//echo $_SESSION['shell'];
$action = new action();
$action ->get_show_msg('admin/admin_main.php', $show = '操作已成功!');
}
}else
echo "<script language=javascript>alert('验证码错误');</script>";

?>
<!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>
<link href="style/global.css" rel="stylesheet" type="text/css">
<link href="style/link.css" rel="stylesheet" type="text/css">
<link href="style/layoutid.css" rel="stylesheet" type="text/css">
<script language="javascript">
function chform (obj) {
if (obj.username.value == "") {
alert("请输入用户名!");
obj.username.focus();
return false;
}
if (obj.password.value == "") {
alert("请输入密码!");
obj.password.focus();
return false;
}
if (obj.sccode.value == "") {
alert("请输入验证码!");
obj.sccode.focus();
return false;
}
return true;
}
function RefreshImage(id)
{
document.getElementById(id).src ='Confirm.php?'+Math.random(1);
}
</script>
</head><body>
<!--用户登录开始-->
<div class="login">
<form id="form1" name="form1" method="post" action="" onsubmit="return chform(this)">
<ul>
<li class="loginbtbj fright" style="background-image: url("images/hydl.gif");"><a title="" href="javascript:%20close();"><img src="images/close.gif" alt="关闭" align="right" border="0" height="18" width="18"></a></li>
<li class="fyellowxx fcenter">
.............................................................................................................
</li>
<li class="padleft43">
用户名:<input name="username" size="15" style="width: 150px;" type="text">
</li>
<li class="padleft43">
密码:<input name="password" size="15" style="width: 150px;" type="password">
</li>
<li class="padleft43">
验证码:<input name="sccode" size="6" style="width: 50px;" type="text"><img id="re_confirm" onclick="RefreshImage('re_confirm')" src="Confirm.php">
<a title="看不清?" href="#" onclick="RefreshImage('re_confirm')">看不清?</a> <a href=register.php >注册</a>

</li>
<li class="fyellowxx fcenter">
.............................................................................................................
<br>
<input name="Submit" src="images/dl.gif" style="border: 0pt none; width: 80px; height: 31px;" type="image">
</li>
</ul>
</form>
</div>
<!--用户登录结束-->
</body></html>
这个是验证码的程序 confirm.php 图片什么的代码我就不穿了 LZ可以借鉴下 有一点需要注意 就是这个confirm文件里面不能报错 我在这卡了很久
因为header这个之前不能输出文本 所以如果报错 就会无法显示验证码
<?php
session_start();
$random='';
for($i=1;$i<5;$i++){
$random .= dechex(rand(1,15));}
$_SESSION['rand']=$random;
$im = imagecreatetruecolor(40,20);
$bg = imagecolorallocate($im,0,0,0);
$te = imagecolorallocate($im,255,255,255);
imagestring($im,rand(1,6),rand(1,6),rand(1,6),$random,$te);
header("Content-type: image/jpeg");
imagejpeg($im);
?>

G. php中文验证码无法显示

session_start();
$image=imagecreatetruecolor(200,60);//创建画布
$color=imagecolorallocate($image,mt_rand(157,255),mt_rand(157,255),mt_rand(157,255));//随机颜色
//$color=imagecolorallocate($image,255,255,255);
imagefill($image,0,0,$color);//填充颜色
//中文验证码
$fontface="simhei.ttf";//确保相同目录下有该字体
$strdb=array('好','多','人','在','学','习');
for($i=0;$i<4;$i++){
$fontsizecolor=imagecolorallocate($image,mt_rand(0,150),mt_rand(0,150),mt_rand(0,150));
$codex=iconv("GB2312","UTF-8",$strdb[mt_rand(0,5)]);//iconv不能转数组取任意下标
imagettftext($image,mt_rand(20,24),mt_rand(-30,30),(40*$i+20),mt_rand(30,35),$fontsizecolor,$fontface,$codex);//如果用$code的话就生成1+2+3+4是个汉字的验证码了

}

//干扰点
for($i=0;$i<200;$i++){
$pointcolor=imagecolorallocate($image,mt_rand(50,200),mt_rand(50,200),mt_rand(50,200));
imagesetpixel($image,mt_rand(1,100),mt_rand(1,20),$pointcolor); //雪花
}
//干扰线
for($i=0;$i<3;$i++){
$linecolor=imagecolorallocate($image,mt_rand(50,200),mt_rand(50,200),mt_rand(50,200));
imageline($image,mt_rand(1,99),mt_rand(1,99),mt_rand(1,99),mt_rand(1,99),$linecolor);
}
ob_clean();
header("Content-type:image/png");
imagepng($image);
imagedestroy($image);

H. php验证码显示不出来

输出图像imagejpeg($iamge);
单词拼写错误,应该是 $image

热点内容
知识图谱算法 发布:2024-05-08 20:33:19 浏览:907
手机登云服务器windows 发布:2024-05-08 20:32:57 浏览:112
上传3d模型 发布:2024-05-08 20:11:41 浏览:603
国内访问外国网站 发布:2024-05-08 20:09:40 浏览:859
wifi热点无internet访问 发布:2024-05-08 20:09:37 浏览:892
林肯哪个配置最好 发布:2024-05-08 20:02:42 浏览:68
java变量的声明 发布:2024-05-08 19:50:44 浏览:977
c语言大数阶乘 发布:2024-05-08 19:40:51 浏览:543
华为手机上滑自动出来清理缓存 发布:2024-05-08 19:29:21 浏览:284
如何取消打印机共享密码 发布:2024-05-08 19:24:23 浏览:241