反垃圾邮件字段的形式

时间:2012-10-11 15:24:01

标签: php forms

我正在使用vtiger并在我使用此代码的网站联系页面上收到大量垃圾邮件

        <form name="contact" action="REMOVED" method="post" accept-charset="utf-8"> 
    <input type="hidden" name="publicid" value="REMOVED"></input>
    <input type="hidden" name="name" value="contact"></input>        
    <label>First Name</label>
    <input type="text" value="" name="firstname"  required="true"></input>  
    <label>Phone</label>
    <input type="text" value="" name="phone"  required="true"></input>  
    <label>Last Name</label>
    <input type="text" value="" name="lastname"  required="true"></input>   
    <label>Email</label>
    <input type="text" value="" name="email"  required="true"></input>  
    <label><span>*</span>Street</label>
    <input type="text" value="" name="lane"  ></input>  
    <label><span>*</span>Postal Code</label>
    <input type="text" value="" name="code"  ></input>  
    <label><span>*</span>City</label>
    <input type="text" value="" name="city"  ></input>  
    <label>Country</label>
    <input type="text" value="" name="country"  ></input>   
    <label><span>*</span>County</label>
    <input type="text" value="" name="state"  ></input> 
        <label for="comments"><span>*</span>Description</label>d
    <textarea name="description" cols="40" rows="3" name="description"  id="description"></textarea>

isue即时通讯是提交到另一个不在网站上的网址,我尝试的每个反垃圾邮件方法(12 + 1 =)仍然发送表单,无论答案

我删除了指向网站的链接

对此的任何帮助都很棒

2 个答案:

答案 0 :(得分:3)

在您不使用的表单中添加一个额外字段。用css隐藏它。

访问该页面的垃圾邮件机器人将填满所有字段,即使它们未显示。

如果隐藏字段中有内容,则整个表单都是垃圾邮件,您可以丢弃数据。

答案 1 :(得分:1)

我建议使用其他反垃圾邮件方法 - 使用令牌/私钥。

在HTML表单中你放了这个:

<form action="..." method="post">
<?php
$publicKey = rand()%9;
$privateKey = 0.9;
$token = sha1( $publicKey * $privateKey + $privateKey );    
?>
<input type="hidden" name="publicKey" value="<?php echo $publicKey; ?>" />
<input type="hidden" name="token" value="<?php echo $token; ?>" />
</form>


并在IF条件之前添加几行代码 - 例如:带有SQL查询或发送邮件的片段,只是通过POST方法检查/验证已发送的令牌:

<?php
$publicKey = $_POST['publicKey'];
$privateKey = 0.9;
$token = sha1( $publicKey * $privateKey + $privateKey );

if ( $token == $_POST['token'] ) {

// do something, eg: SQL query, send mail

}
?>

记住! 始终验证并清理所有输入数据! :)