PHP 发送邮件混淆表单标签或根本不显示



我正在尝试制作这个 sendmail 表单,但它要么不显示任何输入,要么将输入放在不同的字段中,尽管其中一些似乎出于某种原因有效。我有表格在 http://nomaddad.net/market/apply.html

我正在使用的PHP是:

<?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 = "admin@centennialmarket.ca";
/*
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 = "../contact.html";
$error_page = "error_message.html";
$thankyou_page = "../thankyou.html";
/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$busname = $_REQUEST['busname'] ;
$Applicant = $_REQUEST['Applicant'] ;
$street = $_REQUEST['street'] ;
$apartment = $_REQUEST['apartment'] ;
$city = $_REQUEST['city'] ;
$province = $_REQUEST['province'] ;
$postal = $_REQUEST['postal'] ;
$mainphone = $_REQUEST['mainphone'] ;
$cellphone = $_REQUEST['cellphone'] ;
$email_address = $_REQUEST['email_address'] ;
$website = $_REQUEST['website'] ;
$category = $_REQUEST['category'] ;
$directorder = $_REQUEST['directorder'] ;
$other = $_REQUEST['other'] ;
$Productdescription = $_REQUEST['Productdescription'] ;
$OctDates = $_REQUEST['OctDates'] ;
$NovDates = $_REQUEST['NovDates'] ;
$DecDates = $_REQUEST['DecDates'] ;
$Power = $_REQUEST['Power'] ;
$Powerfor = $_REQUEST['Powerfor'] ;
$websitepermission = $_REQUEST['websitepermission'] ;
$checkbox = $_REQUEST['checkbox'] ;
$Rules = $_REQUEST['Rules'] ;
$msg = 
"Business Name: " . $busname . "rn" . 
"Applicant Name: " . $Applicant . "rn" . 
"Street: " . $street . "rn" . 
"apartment: " . $apartment . "rn" . 
"City: " . $city . "rn" . 
"Province: " . $province . "rn" . 
"Postal Code: " . $postal . "rn" . 
"Main Phone: " . $mainphone . "rn" . 
"Cell Phone: " . $cellphone . "rn" . 
"Email: " . $email_address . "rn" .
"Website: " . $website . "rn" . 
"Product Category: " . $category . "rn" . 
"Direct Order: " . $directorder . "rn" . 
"Other: " . $other . "rn" . 
"Product Description: " . $Productdescription . "rn" . 
"October Dates: " . $OctDates . "rn" . 
"November Dates: " . $NovDates . "rn" . 
"December Dates: " . $DecDates . "rn" . 
"Power: " . $Power . "rn" . 
"Power For: " . $Powerfor . "rn" . 
"Website Permission: " . $websitepermission . "rn" . 
"Info to give out: " . $checkbox . "rn" . 
"Read the Rules: " . $Rules  ;

/*
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['email_address'])) {
header( "Location: $feedback_page" );
}
// If the form fields are empty, redirect to the error page.
if (empty($Applicant) || empty($email_address)) {
header( "Location: $error_page" );
}
*/
/* 
If email injection is detected, redirect to the error page.
If you add a form field, you should add it here.
*//*
elseif ( isInjected($email_address) || isInjected($Applicant)  || isInjected($busname) || isInjected($postal)  || isInjected($Street)  || isInjected($city)  || isInjected($Applicant)  ||) {
header( "Location: $error_page" );
}
// If we passed all previous tests, send the email then redirect to the thank you page.
else*/ {
mail( "$webmaster_email", "Feedback Form Results", $msg );
header( "Location: $thankyou_page" );
}
?>

我通过电子邮件发送给我的结果是:

公司名称:

申请人姓名:申请人姓名

街道: www.tallgrassapparel.com

公寓:

城市:

省:

邮政编码:

主要电话:

手机:

电子邮件:

网站:

产品类别:

直接订购:直接

其他:其他

产品描述:产品描述 十月 日期: 11月 日期: 19 十二月 日期: 24

功率:是

力量:接管世界

网站权限:否

要提供的信息:

阅读规则:签名

您的表单字段与您从$_POST抓取的内容不匹配

从表格:

<td colspan="4"><div class="form-group">
<label class="col-md-4 control-label" for="prependedtext"></label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon">Business Name:</span>
<input id="prependedtext" name="prependedtext" class="form-control" placeholder="" type="text" required="">
</div>  
</div>

您的商家名称字段名为"prependedtext",但您期望busname

那些有效的命名是一致的。浏览表单并验证所有输入字段的名称,并确保它们都匹配。

此外,看起来有人只是复制并粘贴了代码,而没有仔细检查它。

<input id="street" name="street" class="form-control" placeholder="" type="text" required="">

用于一堆字段。

最新更新