讲师中心 微信公众号

工具推荐

视频效率加速
Laper
Laper

剧本策划到成片协作

AniShort
AniShort

AI短剧协同制作平台

updream

一键生成高质量推广成片

立刻MV
立刻MV

低成本歌曲 MV、视频生成

上到到空间后验证码不显示?

浅丽小哥_2677

浅丽小哥_2677

发布时间:2016-06-23 14:18:43

|

1339人浏览过

|

来源于php中文网

原创

我在自己的电脑上运行验证码是显示的,怎么我上传到网上空间就不显示啦,是什么原因啊?


回复讨论(解决方案)

你的验证码是用什么方式写的?
看下空间上是否有开启这个功能
如果有,看下有没权限创建这个验证码

注释掉声明数据类型的 header 函数,用浏览器直接运行生成程序

<?php    //随机字符串种子,可以换成字母或其他英文字符    $glbVerifySeed = "AbcDefGhijkL1234567890mnOpqRstuvwxYz";    main();            function main() {        session_start();                $verifyCode = getRandomCode();        $_SESSION["verifyCode"] = $verifyCode;        $imgWidth = $_REQUEST["width"];        $imgHeight = $_REQUEST["height"];        $imgFont = $_REQUEST["font"];                if($imgWidth == "") $imgWidth = 50;        if($imgHeight == "") $imgHeight = 20;        if($imgFont == "") $imgFont = 6;        doOutputImg($verifyCode, $imgWidth, $imgHeight, $imgFont);    }        //获取随机数字字符串    function getRandomCode($length=4) {        global $glbVerifySeed;                $bgnIdx = 0;        $endIdx = strlen($glbVerifySeed)-1;                $code = "";        for($i=0; $i<$length; $i++) {            $curPos = rand($bgnIdx, $endIdx);            $code .= substr($glbVerifySeed, $curPos, 1);        }                return $code;    }        //输出校验码图像    function doOutputImg($string, $imgWidth, $imgHeight, $imgFont,        $imgFgColorArr=array(0,0,0), $imgBgColorArr=array(255,255,255)) {        $image = imagecreatetruecolor($imgWidth, $imgHeight);        //用白色背景加黑色边框画个方框        $backColor = imagecolorallocate($image, 255, 255, 255);        $borderColor = imagecolorallocate($image, 255, 255, 255);        imagefilledrectangle($image, 0, 0, $imgWidth - 1, $imgHeight - 1, $backColor);        imagerectangle($image, 0, 0, $imgWidth - 1, $imgHeight - 1, $borderColor);        $imgFgColor = imagecolorallocate ($image, $imgFgColorArr[0], $imgFgColorArr[1], $imgFgColorArr[2]);        doDrawStr($image, $string, $imgFgColor, $imgFont);        doPollute($image, 64);        header('Content-type: image/png');        imagepng($image);        imagedestroy($image);    }    //画出校验码    function doDrawStr($image, $string, $color, $imgFont) {        $imgWidth = imagesx($image);        $imgHeight = imagesy($image);                $count = strlen($string);        $xpace = ($imgWidth/$count);                $x = ($xpace-6)/2;        $y = ($imgHeight/2-8);        for ($p = 0; $p<$count;  $p ++) {            $xoff = rand(-2, +2);            $yoff = rand(-2, +2);            $curChar = substr($string, $p, 1);            imagestring($image, $imgFont, $x+$xoff, $y+$yoff, $curChar, $color);            $x += $xpace;        }        return 0;    }        //画出一些杂点    function doPollute($image, $times) {           $imgWidth = imagesx($image);        $imgHeight = imagesy($image);        for($j=0; $j<$times; $j++) {            $x = rand(0, $imgWidth);            $y = rand(0, $imgHeight);                        $color = imagecolorallocate($image, rand(0,255), rand(0,255), rand(0,255));            imagesetpixel($image, $x, $y, $color);        }    }?>

验证码是这样写的。
<?require_once('lib07/function_form.inc.php');require_once('lib07/config.inc.php');if(!defined('dbzz_net')) {	exit('Access Denied');}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title><?=$global_websitename;?></title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link href="css/style.css" rel="stylesheet" type="text/css" /><script language="javascript"><!--function FormCheck() {  if (myform.userid.value=="")  {    alert("请您填写用户ID!");    document.myform.userid.focus();    return false;  }var filter=/^\s*[A-Za-z0-9_-]{4,20}\s*$/;if (!filter.test(document.myform.userid.value)) { alert("用户名填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 下划线 减号)长度不小于4个字符,不超过20个字符,注意不要使用空格。"); document.myform.userid.focus();//document.myform.username.select();return false; }    if (myform.pwd.value=="")  {    alert("请您填写密码!");    document.myform.pwd.focus();    return false;  }  if(myform.check.value==""){	   alert ("验证码必须填写!");	   myform.check.focus();	   return false;}var filter=/^\s*[A-Za-z0-9_-]{4,20}\s*$/;if (!filter.test(document.myform.pwd.value)) { alert("密码填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 下划线 减号)长度不小于4个字符,不超过20个字符,注意不要使用空格。"); document.myform.pwd.focus();document.myform.pwd.select();return false; }        return true;  }//function shutwin(){opener=null;self.close();}////function showme1() {//window.open("","pop","scrollbars=no,status=yes,resizable=yes,top=0,left=0,width="+(screen.availWidth-10)+",height="+(screen.availHeight-30)+",channelmode=no");//shutwin();//}function textLimitCheck(thisArea, maxLength){    if (thisArea.value.length > maxLength)	{      alert(maxLength + ' 个字限制. \r超出的将自动去除.');      thisArea.value = thisArea.value.substring(0, maxLength);      thisArea.focus();    }    /*回写span的值,当前填写文字的数量*/  }function change()  	{  	var img =document.getElementById("codeimg");  	img.src=img.src+"?";  	}  //--></script></head><body style="background:#145597 url(myimages/one/login_back.gif) repeat-x top;" scroll=no><table width="1004" height="618" border="0"  cellpadding="0" cellspacing="0" background="myimages/1/loginback.jpg">  <tr>    <td align="center" ><table width="498" height="222" border="0" cellpadding="0" cellspacing="9" bgcolor="215992">        <tr>          <td background="myimages/1/loginback_mid.jpg" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">              <tr>                <td height="40"  class="websitename">    金科网络公司OA系统登录</td>              </tr>              <tr>                <td><form name="myform" method="post" onSubmit="return FormCheck();" action="userinfo/login.php">                    <table width="100%" border="0" cellspacing="0" cellpadding="2">                      <tr>                         <td width="25%" height="26" align="right"><font color="#0057AE">账 号:</font></td>                        <td width="38%"><input name="userid" type="text" id="Uname" style="width:148px;padding-bottom:2px;padding-left:3px;line-height:22px;margin:0px auto;" tabindex=1 size="18" maxlength="20"></td>                        <td width="37%" rowspan="3"><input type="image" src="myimages/1/loginbutton.gif" name="Submit" style="height:62px;width:62px;border:0px;" width="62" height="62" tabindex=3 value="-立刻登录-" >                         </td>                      </tr>                      <tr>                         <td height="26" align="right"><font color="#0057AE">密 码:</font></td>                        <td><input name="pwd" type="password" id="Upass" style="width:148px;padding-bottom:2px;line-height:22px;padding-left:3px;margin:0px auto;" tabindex=2 size="20" maxlength="20" ></td>                      </tr>					  <tr>                         <td height="26" align="right"><font color="#0057AE">验证码:</font></td>                        <td><input type="text" name="check" style="width:148px;padding-bottom:2px;padding-left:3px;line-height:22px;margin:0px auto;" tabindex=1 size="18" maxlength="20"></td></tr>						<tr><td> </td><td><img  src="userinfo/Verifycode.php" onClick="this.src='userinfo/Verifycode.php?rand='+Math.random()*5;"   style="max-width:90%" id="codeimg"/ alt="上到到空间后验证码不显示?" > <a href="javascript:change();" style="cursor:pointer;">看不清楚,换一张</a></td>                      </tr>                    </table>                  </form></td>              </tr>              <tr>                <td  style="max-width:90%" style="color:#53a3c6;line-height:22px;">    业务部专用<br>                   </td>              </tr>            </table></td>        </tr>      </table></td>  </tr></table></body></html>

调用是这样调用的

这样写在本地只要把wamp里面的php_gd2选上就行显示啦,怎么上传到空间后就没有显示啦呢?请帮帮我,谢谢!

空间里面 gd开启了嘛?报什么错?

空间里面 gd开启了嘛?报什么错?
空间是买的,怎么开gd啊,没有报错,就是不显示,直接不显示。

Notice:  Undefined index: width in .... on line 11
Notice:  Undefined index: height in ... on line 12
Notice:  Undefined index: font in ... on line 13

而你只有 上到到空间后验证码不显示? 并没有传入参数

Notice:  Undefined index: width in .... on line 11
Notice:  Undefined index: height in ... on line 12
Notice:  Undefined index: font in ... on line 13

而你只有 上到到空间后验证码不显示? 并没有传入参数
那应该怎么写?麻烦你教一下,谢谢!

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
超级麦吉

一款通过数字员工协作完成调研、数据分析与文档制作的AI办公平台。

讯飞绘文

讯飞绘文是一款由科大讯飞推出的一站式 AIGC 内容运营平台。

Flowith
Flowith Hot

Flowith是一款基于画布和智能体工作流的 AI 协作工作空间。

咔片AIPPT

一款在线AI演示文稿制作工具,可根据主题和内容需求辅助生成PPT结构与页面,提高演示材料制作效率。

豆包大模型

豆包大模型是一款由字节跳动推出的企业级大语言模型服务平台。

DeepSeek

DeepSeek是一款面向对话、写作、编程和推理场景的AI大模型工具。

SkildArt
SkildArt Hot

SkildArt是一款AI文本写作工具,一站式 AI 视觉创作平台。

墨刀AI
墨刀AI Hot

一款AI图像与设计工具,主要用于产品经理的专属智能体,适合需要提升相关任务效率的用户。

WorkBuddy

一款AI办公效率工具,主要用于腾讯云推出的AI原生桌面智能体工作台,适合需要提升相关任务效率的用户。

相关专题

更多
Nginx CVE-2026-123007排查与防护指南
Nginx CVE-2026-123007排查与防护指南

Nginx HTTP/2漏洞该怎么修复?本专题围绕CVE-2026-123007,介绍安全版本升级、模块兼容检查和配置恢复方法,以及日志排查、权限设置等后续加固操作,方便你按实际部署情况查找对应教程。

0

2026.11.20

GoFrame框架Web开发与路由中间件
GoFrame框架Web开发与路由中间件

本专题聚焦GoFrame框架的Web开发,拆解路由注册与匹配规则、请求参数获取、参数校验与中间件执行顺序,说明统一响应、JWT鉴权、文件上传与接口文档生成的落地方式,并补充优雅重启与测试实践。

40

2026.11.17

GoFrame框架安装与gf命令行工具
GoFrame框架安装与gf命令行工具

本专题围绕GoFrame框架的安装与工具链配置展开,讲清Go版本要求、gf命令行的安装方式、代理镜像与依赖准备,说明项目初始化、热编译、交叉编译打包的做法,并整理安装阶段的常见报错与验证步骤。

60

2026.11.17

GoFrame框架零基础入门
GoFrame框架零基础入门

本专题整理GoFrame框架的入门知识,从模块化设计理念、环境准备到跑通第一个Web服务,讲清目录分层、配置加载、日志与中间件的用法,并对比Gin、Go-Zero的差异,帮助Go开发者建立整体认知。

80

2026.11.17

SQLAlchemy 一对多关系怎么建立
SQLAlchemy 一对多关系怎么建立

SQLAlchemy 一对多关系怎么建立?本专题整理父子表外键、relationship 双向映射、关联查询、级联删除和加载优化等相关文章,帮助你理解并实现常见的 ORM 关系建模。

20

2026.11.17

SQLAlchemy 如何增删改查
SQLAlchemy 如何增删改查

SQLAlchemy 如何增删改查?本专题整理 ORM 新增记录、条件查询、更新和删除、Session 事务提交与批量处理等实用文章,帮助你掌握 Python 数据库操作流程。

80

2026.11.17

SQLAlchemy ORM 模型怎么写
SQLAlchemy ORM 模型怎么写

SQLAlchemy ORM 模型怎么写?本专题整理模型类定义、Mapped 字段映射、主键与约束、表结构创建和常见报错的相关文章,帮助你从基础配置到实际建模逐步掌握 SQLAlchemy。

40

2026.11.17

Go-Zero API开发使用教程
Go-Zero API开发使用教程

本专题聚焦Go-Zero的API开发,拆解.api描述文件的语法结构、路由与分组定义、参数绑定与校验规则,说明统一响应体、JWT鉴权、跨域与接口文档生成的落地方式,并给出网关聚合与接口测试的实践建议。

180

2026.11.12

Go-Zero安装与goctl环境配置教程
Go-Zero安装与goctl环境配置教程

本专题围绕Go-Zero的安装与工具链配置展开,讲清Go版本要求、goctl安装方式、代理镜像、protoc依赖与环境变量设置,说明多版本共存、升级回退与CI流水线安装的做法,并整理安装阶段的常见报错与验证步骤。

140

2026.11.12

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn