和smarty没关系。
用php和验证码,一搜一大把
用php和验证码,一搜一大把
解决方案 »
- PHP中遇到的openssl.dll的问题~~请教各路大神啊啊啊啊~~~
- PHP4版本里转换不了编码
- mysql数据超过30M大,怎么还源
- php.ini 问题
- 求做过网站视频的PHP高手
- Fatal error: Call to a member function query() on a non-object in G:\wamp\apache
- PHP:请问怎样将字符串转换为数字,比如将“1000”转换为1000.
- 2003server下连接不上Mysql4.1
- quicktime全屏代码???
- 我急要的验证码代码……
- 这句怎么不能写入文件啊?这句怎么不能写入文件啊?
- 请问,查询大量数据放在表格中显示出来时怎么减少显示时间?谢谢!
session_start();
header ("Content-type: image/jpeg");for($Tmpa=0;$Tmpa<4;$Tmpa++){
$nmsg.=rand(0,9);
}
$_SESSION['validate_code'] = $nmsg;
$im = @imagecreate (48, 18)
or die ("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate ($im, 239, 239, 239);//设置干扰像素,防止被OCR
for ($i=0;$i<=128;$i++)
{
$point_color = imagecolorallocate ($im, rand(0,255), rand(0,255), rand(0,255));
imagesetpixel($im,rand(2,128),rand(2,38),$point_color);
}//逐个画上验证码字符
for ($i=0;$i<=3;$i++)
{
$text_color = imagecolorallocate ($im, rand(0,255), rand(0,128), rand(0,255));
$x = $i * 12;
$y = rand(5,10);
imagechar ($im, 5, $x, 2, $_SESSION['validate_code']{$i}, $text_color);
}//输出PNG图像
imagepng ($im);imagedestroy ($im);
?> index.php //登录界面<?php
require_once "./includes/global.php";
$tpl->display("index.htm");
?>index.htm //登录界面模板
<html>
<head>登录</head>
<body>
<form name="login" method="post" action="login.php">
用户名:<input type="text" name="username" value=""><br>
密 码:<input type="password" name="password" value=""><br>
验证码:<input type="text" name="validate_code" value=""><IMG src="./includes/check_code.php" width="46" height="18">
</body>
</html>可是传递到login.php以后,发现$_SESSION['validate_code']这个变量不存在,请问我是不是哪里写错了呢?
不存在,faint
-----------------------
直接在index.php中答应$_SESSION['validate_code']也不行,也是不存在