<?php
$connect=mysql教程_connect("localhost","root","")or die("服务器连接失败");
mysql_select_db("test",$connect)or die("没有建立相应的数据库");
$sql="select * from admin";
?>
图片验证码 piccheck.php
代码如下
复制代码
<?php
/*
* Created on 2011-8-10
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclips教程e - PHP - Code Templates
*/
session_start();
$code=rand(0,9).dechex(rand(10,15)).rand(0,9).dechex(rand(10,15));
$_SESSION[pic]=$code;
$image=imagecreatetruecolor(50,18);
$color=imagecolorallocate($image,0,0,0);//第一次使用调色板,会设为背景颜色
$colortext=imagecolorallocate($image,rand(100,255),rand(100,255),rand(100,255));
imagestring($image,10,rand(1,15),rand(1,5),$code,$colortext);
imagegif($image);
?>
PHP之友评论