我在网上搜索了一个脚本让它发送一个表格到你的邮箱。但是当我按下提交按钮时,我会来到感谢页面。所以它应该发送。但事实并非如此。 有人可以帮我吗?为什么我的表单邮件脚本不起作用?
发送脚本:
<?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