首页 > Web开发 > 详细

php验证码

时间:2015-04-18 22:04:53      阅读:275      评论:0      收藏:0      [点我收藏+]
<html>
<title>用户注册</title>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script language="javascript">
function check()
{
	if(myform.username.value == "")
	{
		alert("用户名不能为空!");
		myform.username.focus();
		return false;
	}
	if(myform.pwd.value == "")
	{
		alert("密码不能为空!");
		myform.pwd.focus();
		return false;
	}
	if(myform.ccode.value == "")
	{
		alert("验证码不能为空!");
		myform.ccode.focus();
		return false;
	}
	return true;
}
</script>
</head>
<body>

<form action="" method="post" onsubmit="javascript:return check()" name="myform">
<label for="user">姓    名:</label>
<input type="text" name="username" id="user"/><br>
<label for="pwd">密    码:</label>
<input type="password" name="pwd" id="pwd"/><br>
<label for="ccode">验证码:</label>
<input type="text" name="ccode" id="ccode">
<?php 
	$num=mt_rand(1000,9999);
	for($i=0;$i<4;$i++)
	{
		$n=substr($num,$i,1);
		echo "<image src='images/code/$n.gif'>";
	}
?>
<br>                
<input type="submit" name="sub" value="提交"/>
</form>

</body>
</html>

php验证码

原文:http://blog.csdn.net/cjc211322/article/details/45116419

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!