登陆验证码
来源:互联网 发布:淘宝男装店铺名称 编辑:程序博客网 时间:2024/06/05 02:41
<!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>
<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);
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);
?>
0 0
- 登陆、注册 时候 验证码 验证登陆。
- 生成登陆验证码
- 登陆验证码
- jsp 登陆验证码
- Java 登陆验证码
- .net登陆验证码
- .net登陆验证码
- 登陆验证码-----实现
- oauth 验证码登陆
- 登陆验证码
- MVC 登陆验证码
- JavaWeb登陆验证码
- 登陆验证码
- 验证码登陆demo
- Java 登陆验证码
- jsp登陆验证码
- 登陆验证码实现
- 登陆用的验证码
- iOS 生成静态库.a文件
- ARM的Trustzone是怎样保证硬件安全的
- Swift 3.0 【Swift 3.0 相较于 Swift 2.2 的变化】
- PAT 乙级 1009 说反话
- Ubuntu从字符界面打开图形界面,别用startx
- 登陆验证码
- 2.支持向量机概念详解
- 弹出提示框,确认、取消按钮分别转跳到不同的网页
- Linux的五个查找命令:find,locate,whereis,which,type
- 相比于深度学习,传统的机器学习算法难道就此没落了吗,还有必要去学习吗?
- Hibernate联合主键映射
- 属性驱动,模型驱动及动态方法调用
- 几句代码快速集成自定义转场效果+ 全手势驱动
- Python之美[从菜鸟到高手]--装饰器之使用情景分析