生成验证码

来源:互联网 发布:wsn网络分析器sniffer 编辑:程序博客网 时间:2024/06/05 13:26

一 代码

<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"> <?phpfunction 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>

 

二 运行结果

 



 
原创粉丝点击