reCaptcha破坏了我的代码

时间:2011-02-18 02:22:49

标签: php recaptcha

我已经连续几周收到垃圾邮件了。我能够通过表单在我的几个页面上进行一些重新访问,但有一些不起作用。我的一些网站是使用CMS完成的,其他部分是从头开始完成的。所以...有一个名为sign-up.php的页面。这是一个受到最多打击的表单的页面。表单结构有点奇怪。我添加的唯一内容是标记内的php标记和recaptcha脚本。我找到了这个表单发布的文件,但是当我添加google recaptcha告诉我添加的任何内容时,它会崩溃。我试过添加一些简单的行,比如include_once(recaptchalib.php),它仍然会崩溃。

<div class="big_box">

<form name="signup" method="post" action="">



<div class="container_shadowl"></div>

<div class="container">

<div class="h1_title">Sign Up</div>

<p class="cntp cntmleft">

....
<div class="cntcontact">

    <div class="cntbox1a" style="width:285px;padding-top:35px; padding-left:120px !important">



           <input type="hidden" name="submit" value="submitted" />



           <table border="0" cellpadding="0" cellspacing="0" class="input-td">

           <tr>

              <td style="width:110px;" class="ctninput">* First Name</td>

              <td><input name="first_name" type="text" class="cntinputfield"  value="<?=$values['first_name']?>" <?=$field['first_name']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>* Last Name</td>

             <td><input name="last_name" type="text" class="cntinputfield"  value="<?=$values['last_name']?>" <?=$field['last_name']?> style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>* Company</td>

             <td><input name="company" type="text" class="cntinputfield"  value="<?=$values['company']?>" <?=$field['company']?> style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>* Phone</td>

             <td><input name="phone" type="text" class="cntinputfield"  value="<?=$values['phone']?>" <?=$field['phone']?> style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

              <td>* E-Mail (Username - Case Sensitive)</td>

              <td><input name="email" type="text" class="cntinputfield"  value="<?=$values['email']?>" <?=$field['email']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>* Password (Case Sensitive)</td>

             <td><input name="password1" type="password" class="cntinputfield" id="password1" value="<?=$values['password1']?>" <?=$field['password1']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>* Confirm</td>

             <td><input name="password2" type="password" class="cntinputfield"  value="<?=$values['password2']?>" <?=$field['password2']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>Address</td>

             <td><input name="address" type="text" class="cntinputfield"  value="<?=$values['address']?>" <?=$field['address']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>City</td>

             <td><input name="city" type="text" class="cntinputfield"  value="<?=$values['city']?>" <?=$field['city']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>State</td>

             <td><select name="state" class="text2" id="state" class="cntinputfield" style="border:1px solid  #ccc;">



                                    <?



                                    for($i=1;$i<TAMSTATES;$i++){



                                    ?>



                                    <option value="<?=$CMBstateS[$i]?>" <? if(STATEDEFAULTS==$i){?> selected="selected"<? }?>>



                                    <?=$CMBstateS[$i]?>



                                    </option>



                                    <? }?>



                                </select>

             </td>

           </tr>

           <tr>

             <td>Zip</td>

             <td><input name="zip" type="text" class="cntinputfield"  value="<?=$values['zip']?>" <?=$field['zip']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>How Did You Hear About Us?</td>

             <td><input name="hear" type="text" class="cntinputfield"  value="<?=$values['hear']?>" <?=$field['hear']?>  style="border:1px solid  #ccc;"/></td>

           </tr>

           <tr>

             <td>Rep ID or Promo Code</td>

             <td><input name="promo" type="text" class="cntinputfield"  value="<?=$values['promo']?>" <?=$field['promo']?>  style="border:1px solid  #ccc;"/></td>

           </tr>



           </table>

        <p class="cntsmall" style="display:inline">*required fields</p>



           <div class="clear"></div>

    </div>

  <div class="cntbox2" style="width:400px;padding-left:0px !important">

     <!--   <div class="cntcol1" style="width:275px;">





        </div>-->

        <div class="cntcol2" style="width:100%; padding-left:15px;">

          <p><span style="font-size:12px;">Message</span>

            <br />

            <textarea name="message" cols="50" rows="10" class="cntinputfield cnttextarea"  style="margin-top:5px;width:300px;height:75px !important; border:1px solid  #ccc;" ><?=$values['message']?>
          </textarea>

            <br />

            <br />

            <span style="font-size:12px;font-weight:bolder;">Terms and Conditions</span>

            <textarea readonly="readonly" name="terms" cols="50" rows="10" class="cntinputfield cnttextarea"  style="margin-top:5px; width:300px; height:115px !important; border:1px solid  #ccc;" ><?=$terms_conds?>
          </textarea>

            <br />

            <input type="checkbox" name="terms_agree" value="1" />
            <small>I agree to the Terms and Conditions</small>.
          </p>

                <?php
                require_once('recaptchalib.php');
                $publickey = "6LelV8ESAAAAAEo6PETdSv0KvHwbIlM8394qUz0o"; 
                echo recaptcha_get_html($publickey);
                ?>


      <div class="clear"></div>



           <input type="image" style="display:inline; padding-top:10px;" xonclick="document.signup.submit();" src="img/btn_cnt_send.jpg" alt="SUBMIT" />

  </div>

        <div class="clear"></div>

1 个答案:

答案 0 :(得分:0)

我建议你看一下EasyCaptchas,因为与recaptcha相比,使用它是非常容易的(使用PHP)?

该代码示例已损坏:)。查询字符串中缺少?。这是一个正确的例子:

<?php

session_start();

if(isset($_POST['captcha'])) {
    $captcha    = $_POST['captcha'];
    $uid            = $_SESSION['uid'];
    echo file_get_contents("http://www.easycaptchas.com/check.aspx?sessionid=$uid&input=$captcha");
    exit();
}

$uid = $_SESSION['uid'] = uniqid();

?>
<form method="post">
    <input name="captcha" size="16"/>
    <img id="captchaimg" src="http://www.EasyCaptchas.com/<?= $uid; ?>.captcha?" />
    <a href="http://www.easycaptchas.com/" onclick="document.getElementById('captchaimg').src+='rf=1';return false;" style="font-size:9px">refresh</a><br />
    <!-- Free Captcha provided courtesy of www.EasyCaptchas.com (please do not remove this link) -->
    <noscript><a href="http://www.easycaptchas.com/" onclick="return false;" style="display:none">Captcha</a></noscript>
</form>
<script>
    console.log(document.getElementById('captchaimg').src);
</script>