PHP表单sendeail.php无法识别新的表单项

时间:2013-04-23 12:30:10

标签: php html forms

我正在尝试将新项目添加到旧版sendeail.php表单中。但是,当我将新项目添加到php列表和邮件传递时,它们根本不会显示在发送的电子邮件中。至少电子邮件正在通过......我知道我需要优化收音机和复选框项目,但是没有新项目正在显示。新项目是紧接在下面的代码列表中$ attn之后的所有项目。感谢所有的帮助,非常感谢!

我的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>

1 个答案:

答案 0 :(得分:0)

首先:始终验证输入POST)。您已经获得了一些基本验证,但请阅读有关POST数据的安全隐患。

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

您的select代码已损坏,请查看发布的html中的着色。

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

$budget = $_POST['budget'];
$budget = $_POST['day'];
发布时

checkboxes应为数组,将name属性更改为thename[]而不是thename。当然,您的php脚本必须在此更改后处理生成的数组。