代码之家  ›  专栏  ›  技术社区  ›  5AMWE5T

带有Captcha的简单联系人表单HTML?[已关闭]

  •  11
  • 5AMWE5T  · 技术社区  · 12 年前

    我正在寻找具有ReCaptcha或某种反垃圾邮件功能的联系人表单的简单HTML。我尝试了多个教程,但它们都很复杂,我无法得到任何工作。我只需要一个名称、电子邮件和消息字段(以及ReCaptcha和提交按钮)。有人知道我在哪里可以找到简单的联系表单HTML吗?

    4 回复  |  直到 12 年前
        1
  •  11
  •   Professor    12 年前

    如果您一直在努力实施重述,请尝试

    $a=rand(2,9); // this will get a number between 2 and 9
    $b=rand(2,9); // this will also get a number between 2 and 9. You can change this according to your wish
    
    $c=$a+$b;
    

    在php页面上显示

    echo $a."+".$b."="<input type="text" name="recaptcha" />
    

    并检查文本框值是否等于$c。

    这是您可以实现的防止机器人的最简单的概括。

        2
  •  4
  •   user2533777 user2533777    12 年前

    尝试 this 小写: 您可以在论坛中轻松使用它

    <img src="tools/showCaptcha.php" />
    <input type="text" name="captcha"/>
    

    并且它将在会话变量示例中存储captcha值

    if ($_POST["captcha"] == $_SESSION['captcha']) { ... } else { ... }
    
        3
  •  3
  •   Jaykumar Patel    12 年前

    步骤1

    • 您需要一些代码来生成图形字体图像表示web captcha。你一定有 GD library 用于生成字体图像。

      <?php
          session_start();
          $RandomStr = md5(microtime());
          $ResultStr = substr($RandomStr,0,5);
          $NewImage =imagecreatefromjpeg("bgimage.jpg");
      
          $LineColor = imagecolorallocate($NewImage,233,239,239);
          $TextColor = imagecolorallocate($NewImage, 255, 255, 255);
          imageline($NewImage,1,1,40,40,$LineColor);
          imageline($NewImage,1,100,60,0,$LineColor);
      
          $font = imageloadfont("font.gdf");
          imagestring ($NewImage, $font, 5, 5, $ResultStr, $TextColor ); 
          $_SESSION['originalkey'] = $ResultStr;  //store the original coderesult in session variable
      
          header("Content-type: image/jpeg");
          imagejpeg($NewImage);
      ?>
      

      步骤2

    • 现在您的表单调用captcha。

      <form action="submit.php" method="post" name="form1">
          Name:
          <input type="text" name="name" value="" /> <br />
          Email Address:
          <input type="text" name="email" value="" /> <br />     
          Message:
          <textarea name="message" cols="30" rows="6"></textarea> <br />
          <img src="php_captcha.php" />
          <input name="captcha" type="text" id="captcha" size="15" /> <br />
      
          <input type="submit" name="submit" value="Submit" />
          <input type="reset" name="reset" value="clear"/>
      </form>
      

    步骤3

    • 现在,这是形成提交时间检查验证的最后一步。使用会话信息。

      <?php
            $originalkey = substr($_SESSION['originalkey'],0,5);  //session of captcha
            $captcha = $_REQUEST['captchacode'];
            if($captcha!=$originalkey){
              print_error("<b> Captcha does not match, Go back and try again.</b>");
            }
      ?>
      

    希望这对你有所帮助!

        4
  •  1
  •   Gleb Kemarsky    8 年前

    访问这里,这可能会解决您的问题。它的简单形式和解释。

    http://www.html-form-guide.com/contact-form/html-contact-form-captcha.html