这套PHP源码网友是安装成功的,但他不告诉我安装方法,我估计是服务器环境配置不对的原因(不知道是不是的),报错朱如下:
Notice: A session had already been started - ignoring session_start() in D:\xampp\htdocs\index.php on line 1Notice: Undefined index: userid in D:\xampp\htdocs\index.php on line 32还有验证码显示不出来,http://222.243.251.246:888/这是我本地安装的地址,不知道您们能不能打开。请问这样的问题怎么解决? 麻烦详细解释下,本人是菜鸟,谢谢!php
Notice: A session had already been started - ignoring session_start() in D:\xampp\htdocs\index.php on line 1Notice: Undefined index: userid in D:\xampp\htdocs\index.php on line 32还有验证码显示不出来,http://222.243.251.246:888/这是我本地安装的地址,不知道您们能不能打开。请问这样的问题怎么解决? 麻烦详细解释下,本人是菜鸟,谢谢!php
第二个可以通过修改出错提示等级来关闭,这只是个提示。
验证码不显示应该怎么解决呢?
session_start();
session_register('SafeCode');
$type = 'gif';
$width= 60;
$height= 20;
header("Content-type: image/".$type);
srand((double)microtime()*1000000);
$randval = randStr(4,"");
if($type!='gif' && function_exists('imagecreatetruecolor')){
$im = @imagecreatetruecolor($width,$height);
}else{
$im = @imagecreate($width,$height);
}
$r = Array(225,211,255,223);
$g = Array(225,236,237,215);
$b = Array(225,236,166,125); $key = rand(0,3);
$backColor = ImageColorAllocate($im,$r[$key],$g[$key],$b[$key]);//背景色(随机)
$borderColor = ImageColorAllocate($im, 0, 0, 0);//边框色
$pointColor = ImageColorAllocate($im, 255, 170, 255);//点颜色 @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);//背景位置
@imagerectangle($im, 0, 0, $width-1, $height-1, ""); //边框位置
$stringColor = ImageColorAllocate($im, 555,51,153); for($i=0;$i<=100;$i++){
$pointX = rand(2,$width-2);
$pointY = rand(2,$height-2);
@imagesetpixel($im, $pointX, $pointY, $pointColor);
} @imagestring($im, 10, 10, 2, $randval, $stringColor);
$ImageFun='Image'.$type;
$ImageFun($im);
@ImageDestroy($im);
$_SESSION['validationcode'] = $randval;
//产生随机字符串
function randStr($len=6,$format='NUMBER') {
switch($format) {
case 'ALL':
$chars='0123456789'; break;
case 'CHAR':
$chars=''; break;
case 'NUMBER':
$chars='0123456789'; break;
default :
$chars='0123456789';
break;
}
$string="";
while(strlen($string)<$len)
$string.=substr($chars,(mt_rand()%strlen($chars)),1);
return $string;
}
?>
这是验证码文件代码。
注意:一个会话已经开始忽略session_start()应该是你 php.ini 中有
session.auto_start = 1
请改为
session.auto_start = 0
按照您的方法解决了第一条session_start()报错。
Notice: Undefined index: userid in D:\xampp\htdocs\index.php on line 32报错还没有解决,index.php代码如下:
<?php session_start(); ?>
<!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=utf-8" />
<title>用户登录</title>
<link rel="stylesheet" href="Public/css/skins.css" type="text/css" />
<style type="text/css">
body{background:#FFFFFF url(Public/images/body_bg.jpg) repeat-x top center;}
.b{width:660px;margin:0 auto;}
#header{width:100%;height:95px;overflow:hidden;}
.hc{width:800px;margin:0 auto;}
.logo{padding-top:15px;float:left}
.welcome{float:right;width:220px;height:28px;overflow:hidden;background:url(Public/images/login_v1.jpg) 0 0;margin-top:25px;line-height:28px;text-align:center;}
.mainwrap{padding-top:10px;}
#login{width:378px;margin:0 auto;zoom:1;overflow:hidden;border:1px solid #ccc;background:#fff;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px;-webkit-box-shadow:0 0 5px rgba(0, 0, 0, 0.1);-moz-box-shadow:0 0 5px rgba(0, 0, 0, 0.1);box-shadow:0 0 5px rgba(0, 0, 0, 0.1);position:relative;}
.hd{height:29px;line-height:29px;background:#f3f3f3;margin-top:1px;font-size:14px;font-weight:bold;padding:0 8px;}
.bd{margin:0 5px;zoom:1;overflow:hidden;border-bottom:1px dotted #ccc;padding:12px 0 0 20px;}
.bd li{height:45px;font-family:"宋体"}
.bd li img,.bd li a{position:relative}
.inpt{width:230px;padding:2px 3px;height:21px;line-height:21px;border:1px solid #ccc;zoom:1;border-radius:3px;box-shadow:0 1px 6px rgba(0,0,0,0.1);}
.btm{text-align:center;}
.btm p{padding:15px 0 8px 0;}
.sbtn{width:104px;height:30px;border:0;background:url(/static/v1/login_v10.png) 0 -260px no-repeat;cursor:pointer;}
#tip{position:absolute;line-height:17px;top:180px;color:#d41212;top:38px;left:115px;display:none}
li label{color:#4d4d4d;font-size:14px;font-family:新細明體,Tahoma,Arial,Helvetica,sans-serif;}
</style>
</head><?php $userid = $_SESSION['userid'];
if($userid > 0){
echo "<script>window.location.href='highgame';</script>";
}
?>
<body>
<div id="header">
<div class="hc">
<div class="logo"><img src="Public/images/logo.png"></div>
<div class="welcome">xxx <a href="#" target="_blank">欢迎您</a></div>
</div>
</div><div class="mainwrap">
<div id="login">
<div class="hd">用户登录</div>
<div style="clear:both;"></div>
<form method="post" class="loginform" action="<?php if($_POST['setup'] == 1){ echo "post_login.php"; }else{ echo "index.php";} ?>">
<ul class="bd">
<?php if($_POST['setup'] == 1){ ?>
<li>
<label>登陆用户:</label>
<span style="font-weight: bold;font-size:14px;color:blue;"><?php echo $_POST['username']; ?></span><input type="hidden" name="username" value="<?php echo $_POST['username']; ?>" />
</li>
<li>
<label>登陆密码:</label>
<input name="loginpass_source" class="inpt" type="password" value="" datatype="*6-16" nullmsg="请输入密码!" errormsg="密码为6-15位!" />
</li>
<?php }else{ ?>
<li>
<label>用户名:</label>
<input name="username" class="inpt" type="text" value="" datatype="*" nullmsg="请输入用户名!" errormsg="请输入用户名!" />
</li>
<li>
<label>验证码:</label>
<input name="validcode_source" ajaxurl="check.php?act=checkverify" datatype="n4-4" nullmsg="请输入验证码!" errormsg="验证码是4位数字!" style="width:130px;margin-right:15px;" maxlength="4" class="inpt" type="text" />
<img id="verifyImg" src="pub/this.php?r=+Math.random()" title="点击刷新验证码" style="cursor:pointer" onclick="javascript:this.src='/pub/this.php?r='+Math.random();return false;" height="25">
<input type="hidden" name="setup" value="1" /></li>
<?php } ?>
</ul>
<div class="btm">
<p>
<input class="sbtn" type="submit" value="" /> <a href="register.php" style="color:blue;" />注册?</a> <span id="msgdemo2"></span>
</p>
<p>小提示:本系统使用 <span class="red">火狐浏览器,IE8浏览器</span> 可达到最佳浏览效果</p>
</div>
</form>
</div>
</div>
</body>
</html>
<link rel="stylesheet" href="Public/validform/css/style.css" type="text/css" />
<script type="text/javascript" src="Public/validform/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="Public/validform/js/Validform_v4.0_min.js"></script>
<script type="text/javascript">
$(".loginform").Validform({
tiptype:function(msg,o,cssctl){
var objtip=$("#msgdemo2");
cssctl(objtip,o.type);
objtip.text(msg);
},
ajaxPost:false
});</script>另外还有验证码不显示怎么解决?
你可在程序开始处加入
error_reporting(E_ALL ^ E_NOTICE);显示验证码图片须有 GD 库支持
php.ini 中
extension=php_gd2.dll若前面有分号,请删去
变量,没定义吧!。