生成验证码

川长思鸟来 2022-05-11 23:14 474阅读 0赞

一 代码

  1. <style type="text/css">
  2. <!--
  3. .STYLE1 {font-size: 13px}
  4. .STYLE3 {font-size: 13px; font-weight: bold; }
  5. .STYLE4 {
  6. font-size: 20px;
  7. font-family: "华文隶书";
  8. font-weight: bold;
  9. }
  10. -->
  11. </style>
  12. <table width="592" height="260" border="0" align="center" cellpadding="0" cellspacing="0" background="images/bg.jpg">
  13. <tr>
  14. <td width="251" height="30" align="center"> </td>
  15. <td width="99" align="center"> </td>
  16. </tr>
  17. <tr>
  18. <td height="90" align="center" valign="top"><table width="257" height="120" border="0" cellpadding="0" cellspacing="0">
  19. <script language="javascript">
  20. function chkuserinput(form)
  21. {
  22. if(form.yz.value=="")
  23. {
  24. alert("请输入验证码!");
  25. form.yz.select();
  26. return(false);
  27. }
  28. if(form.yz.value!=form.num.value)
  29. {
  30. alert("请输入正确的验证码!");
  31. form.yz.select();
  32. return(false);
  33. }
  34. return(true);
  35. }
  36. </script>
  37. <form name="form2" method="post" onSubmit="return chkuserinput(this)">
  38. <tr>
  39. <td height="10" colspan="3"> </td>
  40. </tr>
  41. <tr>
  42. <td width="60" height="20" align="right" class="STYLE1"><span class="STYLE3">验证码:</span></td>
  43. <td width="70" height="20" class="STYLE1">
  44. <input type="text" name="yz" size="10" class="inputcss" style="background-color:#e8f4ff " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#e8f4ff'"> </td>
  45. <td width="70" align="center" class="STYLE1">
  46. <?php
  47. function make_seed()
  48. {
  49. list($seed, $seeds) = explode(' ', microtime());
  50. return (float) $seeds + ((float) $seed * 100000);
  51. }
  52. mt_srand(make_seed());
  53. $mt_rand = mt_rand();
  54. $num=substr($mt_rand,1,5);
  55. for($i=0;$i<5;$i++)
  56. {
  57. echo "<img src=images/".substr(strval($num),$i,1).".gif>";
  58. }
  59. ?>
  60. </div></td>
  61. </tr>
  62. <tr>
  63. <td height="30" colspan="3" align="center">
  64. <input type="hidden" value="<?php echo $num;?>" name="num">
  65. <input type="submit" class="buttoncss" value="提交">
  66. <label>
  67. <input type="reset" name="Submit" value="重置" />
  68. </label></td></tr>
  69. </form>
  70. </table></td>
  71. <td align="center"> </td>
  72. </tr>
  73. </table>

二 运行结果

d94ad082-bac1-31c5-851e-f636d606d1f5.png

发表评论

表情:
评论列表 (有 0 条评论,474人围观)

还没有评论,来说两句吧...

相关阅读

    相关 验证生成

    视图函数里 > 1,导入图片,画布,画笔,画笔上的字体,定义坐标 > 2,从外部导入字体(字体导入到static静态中) > 3,随机生成验证码,验证码颜色,验证