生成验证码

一 代码

<style type="text/css">
<!--
.STYLE1 {font-size: 13px}
.STYLE3 {font-size: 13px; font-weight: bold; }
.STYLE4 {
	font-size: 20px;
	font-family: "华文隶书";
	font-weight: bold;
}
-->
</style>
<table width="592" height="260" border="0" align="center" cellpadding="0" cellspacing="0" background="images/bg.jpg">
              <tr>
                <td width="251" height="30" align="center">&nbsp;</td>
                <td width="99" align="center">&nbsp;</td>
              </tr>
              
              <tr>
                <td height="90" align="center" valign="top"><table width="257" height="120" border="0" cellpadding="0" cellspacing="0">
					  <script language="javascript">
					     function chkuserinput(form)
						 {
							if(form.yz.value=="")
                            {
							  alert("请输入验证码!");
							  form.yz.select();
							  return(false);
							}
							if(form.yz.value!=form.num.value)
                            {
							  alert("请输入正确的验证码!");
							  form.yz.select();
							  return(false);
							}	
						   return(true);				 
						 }
					  
					  </script>
					     <form name="form2" method="post"  onSubmit="return chkuserinput(this)">
                          <tr>
                            <td height="10" colspan="3">&nbsp;</td>
                          </tr>
                          
                          
                          <tr>
                            <td width="60" height="20" align="right" class="STYLE1"><span class="STYLE3">验证码:</span></td>
                            <td width="70" height="20" class="STYLE1">
                                <input type="text" name="yz" size="10" class="inputcss" style="background-color:#e8f4ff " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#e8f4ff'">                            </td>
                            <td width="70" align="center" class="STYLE1">
				 <?php
						function make_seed() 
						{
                        	list($seed, $seeds) = explode(' ', microtime());
                            return (float) $seeds + ((float) $seed * 100000); 
                        }
                        mt_srand(make_seed());
                        $mt_rand = mt_rand();
            			$num=substr($mt_rand,1,5);
						for($i=0;$i<5;$i++)
						{
							echo "<img src=images/".substr(strval($num),$i,1).".gif>";
						}
				?>
						    </div></td>
                          </tr>
                          <tr>
                            <td height="30" colspan="3" align="center">
                            
                                <input type="hidden" value="<?php echo $num;?>" name="num">
                                <input type="submit" class="buttoncss" value="提交">
                                <label>
                                &nbsp;&nbsp;<input type="reset" name="Submit" value="重置" />
                                </label></td></tr>
					    </form>
                </table></td>
                <td align="center">&nbsp;</td>
              </tr>
</table>

 

二 运行结果

 



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值