簡體   English   中英

反垃圾郵件安全問題php聯系表格

[英]anti spam security question php contact form

我有一個工作聯系字段。 盡管我使用的是標准的垃圾郵件防護工具,例如蜜罐等。但我幾乎每天都會收到垃圾郵件。 所以我想我可能會提出一個安全問題。 所以我添加了這個:

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

現在,我只想在正確回答此問題的情況下發送表格,否則它將顯示錯誤消息。 但是它不再發送但仍顯示成功消息。 我究竟做錯了什么?

我已經將此添加到發送序列中,然后才能正常工作: !empty($_POST['spamprotection']) || ($_POST["spamprotection"] = 'blau') || !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"];

}

您的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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM