码迷,mamicode.com
首页 > Web开发 > 详细

php验证码

时间:2015-04-18 22:05:10      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:php验证码

<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验证码

标签:php验证码

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!