php编写一个注册页面,用php做一个注册页面

在appServ文件夹的www文件夹中创建一个test文件夹,里面存放三个php文件,分别为index.php(用户注册界面),reg.php(验证是否注册成功),auth.php(用于产生验证码)

index.php

注册界面

border-collapse:collapse;

用户注册界面


姓  名:
密  码:
验证码:auth.php

auth.php

//开启session

session_start();

//准备画布资源

$im = imagecreatetruecolor(50,25);

//准备涂料

$balck = imagecolorallocate($im,0,0,0);

$white = imagecolorallocate($im,255,255,255);

$gray = imagecolorallocate($im,200,200,200);

//背景填充

imagefill($im,0,0,$gray);

//在画布上画图像或文字

for($i=0;$i<100;$i++) {

imagesetpixel($im,mt_rand(0,50),mt_rand(0,25),$black);

}

for($i=0;$i<4;$i++) {

imageline($im,mt_rand(0,50),mt_rand(0,25),mt_rand(0,50),mt_rand(0,25),$black);

}

$strarr = array_merge(range(0,9),range(a,z),range(A,Z));

shuffle($strarr);

$str = join('',array_slice($strarr,0,4));

//把$str放入session中,方便在所有页面使用

$_SESSION['vstr'] = $str;

$file = "fonts/simsun.ttc";

imagettftext($im,17,0,2,17,$black,$file,$str);

//输出最终图像或保存最终图像

header("content-type:image/png");

imagepng($im);

//释放画布资源

imagedestroy($im);

?>

reg.php

session_start();

$code = strtolower($_POST['vcode']);

$vstr = strtolower($_SESSION['vstr']);

if($code === $vstr) {

echo "";

}

else {

echo "";

echo "";

}

?>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值