我在網上搜索了一個腳本讓它發送一個表格到你的郵箱。但是當我按下提交按鈕時,我會來到感謝頁面。所以它應該發送。但事實並非如此。 有人可以幫我嗎?爲什麼我的表單郵件腳本不起作用?
發送腳本:
<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "[email protected]";
/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$naam = $_REQUEST['naam'] ;
$wedstrijd1 = $_REQUEST['wedstrijd1'] ;
$wedstrijd2 = $_REQUEST['wedstrijd2'] ;
$wedstrijd3 = $_REQUEST['wedstrijd3'] ;
$wedstrijd4 = $_REQUEST['wedstrijd4'] ;
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['naam'])) {
header("Location: $feedback_page");
}
// If the form fields are empty, redirect to the error page.
elseif (empty($naam) || empty($wedstrijd1) || empty($wedstrijd2) || empty($wedstrijd3) || empty($wedstrijd4)) {
header("Location: $error_page");
}
// If email injection is detected, redirect to the error page.
elseif (isInjected($naam)) {
header("Location: $error_page");
}
// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail("$webmaster_email", "Nieuwe voorspelling ingestuurd!",
$naam,
$wedstrijd1,
$wedstrijd2,
$wedstrijd3,
$wedstrijd4);
header("Location: $thankyou_page");
}
?>
但是,當我刪除所有「wedstrijd」 1,2,3和4的郵件將發送。我在談論的代碼://如果我們通過所有以前的測試,發送電子郵件然後重定向到謝謝頁面。 其他{ 電子郵件( 「$ webmaster_email」, 「NIEUWE voorspelling ingestuurd!」, $ NAAM, $ wedstrijd1, $ wedstrijd2, $ wedstrijd3, $ wedstrijd4); header(「Location:$ thankyou_page」); } – change1001
@ change1001您是否使用開發服務器從您家發送它? –
@AJHenderson那麼我該如何解決這個問題? (回覆您的編輯) – change1001