2013-04-23 24 views
0

我想添加新的项目到传统的sendeail.php表单。但是,当我将新项目添加到php列表和邮件传递时,它们在所发送的电子邮件中根本不显示。至少电子邮件正在经历......我知道我需要改进收音机和复选框项目,但是没有任何新项目正在显示。新项目是紧接在下面的代码列表中的$ attn之后的所有项目。任何和所有的帮助表示赞赏,非常感谢!PHP表单sendeail.php不能识别新的表单项目

我的PHP代码:

<?php 

$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$visitor = $_POST['visitor']; 
$visitormail = $_POST['visitormail']; 
$notes = $_POST['notes']; 
$attn = $_POST['attn']; 
$phone = $_POST['phone']; 
$interest = $_POST['interest']; 
$budget = $_POST['budget']; 
$budget = $_POST['day']; 
$timeslot = $_POST['timeslot']; 

if (eregi('http:', $notes)) { 
die ("Do NOT try that! ! "); 
} 
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{ 
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Please complete all the fields.</h2>\n"; 
echo $badinput; 
die ("Use the Back button on your browser..."); 
} 

if(empty($visitor) || empty($visitormail) || empty($notes) || empty($attn) || empty($phone)) { 
echo "<h2>Please click Back and fill in all fields.</h2>\n"; 
die ("Use the Back button on your browser... "); 
} 

$todayis = date("l, F j, Y, g:i a") ; 

$attn = $attn ; 
$subject = $attn; 

$notes = stripcslashes($notes); 

$message = " $todayis [EST] \n 
Web Site Request About: $attn \n 
From: $visitor ($visitormail)\n 
Phone: $phone \n 
Message: $notes \n 
Interested In: $interest \n 
Heating Budget: $budget \n 
Time Availability: Days - $day \n 
Time Availability: Morning or Afternoon - $timeslot \n 


Additional Info : IP = $ip \n 
Browser Info: $httpagent \n 
Referral : $httpref \n 
"; 

$from = "From: $visitormail\r\n"; 


mail("XXXXX", $subject, $message, $from); 

?> 

而我的HTML代码:

<?php 
$ipi = getenv("REMOTE_ADDR"); 
$httprefi = getenv ("HTTP_REFERER"); 
$httpagenti = getenv ("HTTP_USER_AGENT"); 
?> 
     <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> 
     <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> 
     <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> 
     All fields are required.</p> 
     <p align="left">Your Name: 
     <input type="text" name="visitor" size="35" /> 
     </p> 
     <p align="left"> 
     Your Email: 
      <input type="text" name="visitormail" size="35" /> 
     </p> 
     <p align="left"> 
     <label for="Phone">Your Phone: </label> 
     <input type="text" name="Phone" id="Phone" size="35"/> 
     </span></p> 
     <p align="left"> 
     About: 
     <select name="attn" size="1"> 

select name="interest" id="interest"> 
      <option value="General Query">General question</option> 
      <option value="Plumbing Query">Plumbing</option> 
      <option value="Gasfitting Query">Gasfitting</option> 
      <option value="Central Heating Query">Central Heating</option> 
      <option value="Custom Work Query">Several options</option> 
      </select> 
     <br /> 

    <p align="left">Your Home Heating Budget: 

    <select name="attn2" size="1"> 


select name="budget" id="budget"> 
     <option value="Under 10000">$8000 to $10,0000</option> 
     <option value="10 to 12 Thousand">$10,000 to $12,000</option> 
     <option value="12 to 15 Thousand">$12,000 to $15,000</option> 
     <option value="+15000 Plus">$15,000 +</option> 
     </select> 
    <br /> 
    <p align="left">Are you considering other forms of heating? 
    <input type="checkbox" name="Yes-OtherFormsHeating" id="Yes-OtherFormsHeating" /> 
    <label for="Yes">Yes</label> 
    <input type="checkbox" name="No-OtherFormsHeating" id="No-OtherFormsHeating" /> 
    <label for="No">No</label> 
    <br /> 
    </p> 
    <p align="left">Please give us a few details about your home and requirements: <br /> 
     <textarea name="notes" rows="6" cols="70"></textarea> 
    </p> 


    <p align="left">To give you a quote for gas central heating, we need to visit your home. What is a good day and time for us to come to you? Choose one option.</p> 
    <p align="left"> 
     <input type="radio" name="day" id="day_M" value="M" /> 
     <label for="M">M</label> 
     <input type="radio" name="day" id="day_T" value="T" /> 
     <label for="T">T</label> 
     <input type="radio" name="day" id="day-W" value="W" /> 
     <label for="W">W</label> 
     <input type="radio" name="day" id="day_Th" value="Th" /> 
     <label for="Th">Th</label> 
     <input type="radio" name="day" id="day_F" value="F" /> 
     <label for="F">F</label> 
    </p> 
    <p align="left">When is a good time on this day for us to come to you? Choose one or both.</p> 
    <p align="left"> 
     <input type="checkbox" name="timeslot" id="8:30-12:30AM" /> 
     <label for="8:30-12:30AM">8:30 - 12:30</label> 
     <input type="checkbox" name="timeslot" id="12:30-4" /> 
     <label for="12:30-4">12:30 - 4:00</label> 
    </p> 

回答

0

首先:始终验证输入POST)。您已经进行了一些基本验证,但是已经阅读了关于POST数据的安全性问题。

php中的数组键区分大小写。 $_POST['phone']$_POST['Phone']不一样。

您的select标签坏了,看看您发布的着色html

您已经声明$budget两次,覆盖预期的数据:

$budget = $_POST['budget']; 
$budget = $_POST['day']; 

checkboxes应该阵列贴的时候,改变name属性thename[],而不是仅仅thename。当然你的PHP脚本必须处理这个变化后的结果数组。