【问题标题】:anti spam security question php contact form反垃圾邮件安全问题 php 联系表
【发布时间】:2018-11-10 09:33:23
【问题描述】:

我有一个工作联系人字段。尽管我正在使用标准的垃圾邮件防护工具,例如蜜罐等。但我几乎每天都会收到垃圾邮件。所以我想我可能会给我们一个安全问题。所以我添加了这个:

Spam-question: Which colour has the sky? (lowercase) <input name="spamprotection">

现在我只想在这个问题得到正确回答的情况下发送表单,否则它应该显示错误消息。但它不再发送,但仍然显示成功消息。我做错了什么?

我已将其添加到发送序列中并且在它正常工作之前:!empty($_POST['spamprotection']) || ($_POST["spamprotection"] = 'blau') ||

// Send the email. 

if (!empty($_POST['spamprotection']) || ($_POST["spamprotection"] = 'blau') ||  mail($to, $subject, $message, $header)) {

    $result = ["color" => "green", "msg" => "Ich habe Ihre Mail erhalten und melde mich in Kürze!"];

    if ($file_type) {

      $result['msg'] .= "";

    }

} else {

    $result = ["color" => "red", "msg" => "Nachricht konnte nicht gesendet werden. Bitte senden Sie mir Ihre Anfrage an bm-translations@email.de"];

}

【问题讨论】:

    标签: php contact-form spam


    【解决方案1】:

    您在 if 语句中的逻辑无效。

    你需要把你的代码改成这个。

    if (isset($_POST['spamprotection']) && $_POST["spamprotection"] == 'blau') {
    
        $result = ["color" => "green", "msg" => "Ich habe Ihre Mail erhalten und melde mich in Kürze!"];
        mail($to, $subject, $message, $header);
    
        if ($file_type) {
    
          $result['msg'] .= "";
    
        }
    
    } else {
    
        $result = ["color" => "red", "msg" => "Nachricht konnte nicht gesendet werden. Bitte senden Sie mir Ihre Anfrage an bm-translations@email.de"];
    
    }
    

    谈到平等:

    $a = '5'; //This sets $a = 5(string);
    $b = 5; //This sets $b = 5(int);
    $a == $b;  //This checks to see if $a is equal to $b. Will return true.
    $a === $b; //This is a strict comparison of $a & $b.  It checks to see if $a is equal to $b as well as the type.  Meaning $a(string) is equal to $b(int). Will return false.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-05
      • 1970-01-01
      相关资源
      最近更新 更多