蜜罐不在PHP表单上工作

时间:2017-08-16 01:44:51

标签: php forms spam honeypot

我正在尝试使用这个gem创建一个honeypot字段,但我不确定如何实现它。表格如何知道蜜罐的哪个字段以及我在哪里指定标签?

所以它应该像这样工作:

  1. 用户进入着陆页
  2. 用户看到的注册表包含:

    1. 电子邮件地址输入框
    2. 隐藏的蜜罐字段
  3. 如果机器人注册它将填写蜜罐,所以当创建邀请时,我可以自动接受那些没有填写蜜罐的那些,那些会被拒绝。

  4. 以下是我用于表单的代码

    的index.php

            <div id="customer_lay">
                <h1>Customer Service</h1><br/><br/>
                <div id="enewsletter">
                    <ul>    
                        <p>Subscribe to eNewsletter</p>
                        <li><a href="javascript: alert("eNewsletter informs about newest products, product updates and technical information.If you like to be informed about current issues please leave us your email address.Each newsletter contains a link to unsubscribe from the mailing list');"><img src="images/index/bt_guide.gif" width="65" height="30" /></a></li>
                    </ul>
                    <form name="enewsform" id="enewsform" action="enewsletter_ins.php" onsubmit="return sendData(this)">
                    <dl>
                        <dt>E-mail</dt>
                        <dd><input name="email" type="text" size="20" maxlength="40" id="form_style01"/></dd>
                        <dt>Name</dt>
                        <dd><input name="name" type="text" size="20" maxlength="40" id="form_style01"/></dd>
                        <p><input type=image src="images/index/bt_Subscribe.gif" width="65" height="47" /></a></p>
                        <span style="margin-left:40px" id="errormsg"><a href="#"></a></span>
                    </dl>   
                    </form>
                </div>
    
    
    ----
    
    <?
    include_once $_SERVER[DOCUMENT_ROOT]."/popup_list.php";
    include_once $_SERVER[DOCUMENT_ROOT]."/include/_footer.php";
    ?>
    
    <script src="javascript/jquery.validate.min.js" type="text/javascript"></script>
    <script src="javascript/jquery.blockUI.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#enewsform').validate({
                errorLabelContainer: "#errormsg",
                rules: {
                    email: {required: true, email:true},
                    name: {required: true, minlength:2, maxlength:12},
                },
                messages: {
                    email: {required:" * Required ", email:" * Not Valid Email"},
                    name:  {required:" * Required ", minlength: " * at least 2 characters", maxlength: " * up to 12 chars"}
                }
            });
        });
    </script>
    

    enewsletter_ins.php

    <?
    include_once $_SERVER[DOCUMENT_ROOT]."/include/initiate.php";
    
    
    
    if(trim($name)=="" or trim($email)==""){
        alert("send errer!!");
    }
    
    
    
    $form_title=$email."님의 Subscribe to eNewsletter 신청";
    $user_name=$name;
    $user_email=$email;
    $body="
    date : ".date("Y-m-d H:i:s")."
    <hr>
    Name : $name
    <hr>
    E-Mail : $email
    ";
    
    $sql = "
            insert into prd_form_data set
                form_type = '3',
                form_title = '".$form_title."',
                user_name = '".$user_name."',
                user_email = '".$user_email."',
                user_content = '".$body."',
                insdt = now()
    ";
    mysql_query($sql) or error(mysql_error());
    
    //메일발송
    $comments = $body;
    
    $mailTo     =   ADMIN_MAIL; // 받는 메일 주소;
    $mailFrom   =   "test@example.com"; //  
    
    $mailSubject = "Subscribe to eNewsletter";
    $mailContent = $comments;
    
    $mailHeader = "From: $mailFrom\r\n";
    $mailHeader .= "MIME-Version: 1.0\r\n";
    $mailHeader .= "Content-type: text/html; charset=utf-8\r\n";
    
    $mailResult = mail ($mailTo, $mailSubject, $mailContent, $mailHeader,'-f'.$mailFrom);
    ?>
    
    <form method="post" action="/" name="frm">
    </form>
    
    
    <script type="text/javascript">
    <!--
        alert("ok!!");
        document.frm.submit();
    //-->
    </script>
    

1 个答案:

答案 0 :(得分:0)

您可以在表单中添加一个字段,类型为&#34;隐藏&#34;然后在提交时检查该字段中是否有值。