0

我正在尝试将新项目添加到旧的 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>
4

1 回答 1

0

首先:始终验证输入( POST)。您已经进行了一些基本验证,但还阅读了有关POST数据的安全含义。

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

您的select标签已损坏,请查看您发布的html.

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

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

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

于 2013-04-23T12:49:33.287 回答