登陆验证码
2016-09-29 22:30
155 查看
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>验证码使用</title>
</head>
<body>
<h1>用户登录</h1>
<form action="index.php" method="post">
<input type="text" name="mycheck">
<img src="session5.php" onclick="this.src='session5.php?aa='+Math.random()"/>
<button type="submit">提交</button>
</form>
<?php
if(isset($_POST['mycheck']))
{
$mycheck=$_POST['mycheck'];
session_start();
echo $mycheck;
echo $_SESSION['mycheck'];
if($mycheck==$_SESSION['mycheck'])
{
echo "验证成功";
}
else{
echo "验证失败";
}
}
?>
</body>
</html>
//session.php文件
<?php
session_start();
$check="";
for ($i=0; $i < 4; $i++) {
$check.=dechex(rand(1,15));
}
//将随机验证码保存在session中
$_SESSION['mycheck']=$check;
//创建图片
$img=imagecreatetruecolor(110, 30);
//背景默认为黑色
$bgcolor=imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bgcolor);
//创建新的颜色
$white=imagecolorallocate($img, 255, 255, 255);
$blue=imagecolorallocate($img, 0, 0, 255);
$red=imagecolorallocate($img, 255, 0, 0);
$green=imagecolorallocate($img, 255, 0, 0);
//画出干扰线段
for ($i=0; $i <10 ; $i++) {
imageline($img,rand(0,110),rand(0,30),rand(0,110), rand(0,30),
imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255)));
}
//画噪点
imagestring($img, rand(1,5), rand(2,80), rand(2,10), $check, $white);
header("Content-Type:image/png");
imagepng($img);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>验证码使用</title>
</head>
<body>
<h1>用户登录</h1>
<form action="index.php" method="post">
<input type="text" name="mycheck">
<img src="session5.php" onclick="this.src='session5.php?aa='+Math.random()"/>
<button type="submit">提交</button>
</form>
<?php
if(isset($_POST['mycheck']))
{
$mycheck=$_POST['mycheck'];
session_start();
echo $mycheck;
echo $_SESSION['mycheck'];
if($mycheck==$_SESSION['mycheck'])
{
echo "验证成功";
}
else{
echo "验证失败";
}
}
?>
</body>
</html>
//session.php文件
<?php
session_start();
$check="";
for ($i=0; $i < 4; $i++) {
$check.=dechex(rand(1,15));
}
//将随机验证码保存在session中
$_SESSION['mycheck']=$check;
//创建图片
$img=imagecreatetruecolor(110, 30);
//背景默认为黑色
$bgcolor=imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bgcolor);
//创建新的颜色
$white=imagecolorallocate($img, 255, 255, 255);
$blue=imagecolorallocate($img, 0, 0, 255);
$red=imagecolorallocate($img, 255, 0, 0);
$green=imagecolorallocate($img, 255, 0, 0);
//画出干扰线段
for ($i=0; $i <10 ; $i++) {
imageline($img,rand(0,110),rand(0,30),rand(0,110), rand(0,30),
imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255)));
}
//画噪点
imagestring($img, rand(1,5), rand(2,80), rand(2,10), $check, $white);
header("Content-Type:image/png");
imagepng($img);
?>
相关文章推荐
- extjs 含有验证码的登陆窗口
- python实现带验证码网站的自动登陆实现代码
- Dede织梦验证码不显示,织梦后台登陆验证码不显示解决方法
- android登陆获取验证码倒计时功能的实现(CountDownTimer)
- Flex 带验证码的登陆页面
- python 淘宝系列(二):处理验证码的模拟登陆
- c# 使用 HttpWebRequest模拟登陆(附带验证码)
- 使用PHP实现登陆验证码
- Android模拟登陆带验证码的网站客户端
- 登陆时验证码的生成的代码
- 一个非常实用的带验证码的模拟登陆实例
- [转载]C# winform登陆框验证码的实现
- (二)简单的登陆注册系统--增加验证码部分
- struts2实现验证码登陆
- JEECG--去掉(增加)登陆页面验证码功能
- zz通过snoopy模拟登陆其他有验证码的网站
- 用PHP实现登陆验证码(类似条行码状)
- java抓取带验证码登陆后的页面
- jsp实现登陆验证码
- C# winform登陆框验证码的实现