PHP表单发送带有字段标题的电子邮件,不带收集的数据


PHP form sends email WITH field titles, WITHOUT collected Data

我一直在努力让Php脚本在一周的大部分时间里都能工作:-/。我一直保持着超级简单,但我似乎仍然无法理解这一点。。。奇怪的是
它的功能很好,我收到了带有以下消息的电子邮件:

Name:
Phone number:
Email Address :
Street Address:
Managment Contact:

正如你所看到的,没有任何数据能让我明白。

这是HTML表单:

<td width="487" height="240" bgcolor="#1D1D1D"><form action="Contact form/processrequest.php" method="post" name="request form" target="_parent" id="request form">
              <table width="488" border="0" cellspacing="0" cellpadding="6">
                <tr>
                  <td width="161" height="34" align="right"><label for="name" class="adf">Name </label></td>
                  <td width="303" align="left" bgcolor="#1D1D1D"><input name="Name" type="text" id="Name" size="50" maxlength="200" /></td>
                </tr>
                <tr>
                  <td height="34" align="right" class="adf"><label for="phone">Phone Number </label></td>
                  <td align="left"><input name="Phone Number " type="text" id="Phone Number " size="50" maxlength="300" /></td>
                </tr>
                <tr>
                  <td height="34" align="right" class="adf"><label for="email">Email Address </label></td>
                  <td align="left"><input name="Email Address" type="text" id="Email Address" size="50" maxlength="300" /></td>
                </tr>
                <tr>
                  <td height="34" align="right" class="adf"><label for="street">Street Address </label></td>
                  <td align="left"><input name="Street Address" type="text" id="Street Address" size="50" maxlength="300" /></td>
                </tr>
                <tr>
                  <td height="34" align="right" class="adf"><label for="mgmt">MGMT Contact </label></td>
                  <td align="left"><input name="Management Contact" type="text" id="Management Contact" size="50" maxlength="300" /></td>
                </tr>
                <tr>
                  <td height="36" align="right">&nbsp;</td>
                  <td align="left"><input type="submit" name="Send" id="Send" value="Submit" /></td>

这就是PHP:

<?php
// Get Data 
$name= "$name";
$phone= "$phone";
$email= "$email";
$street= "$street";
$mgmt= "$mgmt";
// Send Message
mail( "myemail@my.com", "Contact From Website",
    "Name: $name 'nPhone number: $phone 'nEmail Address : $email'nStreet Address:              $street'nManagment Contact: $MGMT'n",
    "From: Wearable Collections Facebook App Bin Request Form  <myemail@my.com>" );
    ?>

我觉得我可能错过了一些非常明显的东西——所以任何帮助都将不胜感激!!!!

问题就在这里:

$name= "$name";

要获取表单数据,您应该使用:

$name = $_POST['name'];

对每个表单字段重复此操作,您将获得一组可工作的数据。

这就是获取数据的方式。

按如下方式尝试。

此外,请参阅下面的安全说明。

<?php
    // Get Data 
    $name= $_REQUEST["name"]; // Works for both get and post, as opposed to $_GET["name"] or $_POST["name"];
    $phone= $_REQUEST["phone"];
    $email= $_REQUEST["email"];
    $street= $_REQUEST["street"];
    $mgmt= $_REQUEST["mgmt"];
    // Send Message
    mail( "myemail@my.com", "Contact From Website",
    "Name: $name 'nPhone number: $phone 'nEmail Address : $email'nStreet Address:              $street'nManagment Contact: $MGMT'n",
    "From: Wearable Collections Facebook App Bin Request Form  <myemail@my.com>" );
    ?>

有关使用PHP和Forms的更多信息,请点击此处:

http://php.net/manual/en/tutorial.forms.php

有关$_REQUEST的更多信息,请点击此处:

http://www.php.net/manual/en/reserved.variables.php

重要!!!!!另请参阅这些关于安全性的文章,您应该与表单处理一起学习:

http://phpsense.com/2006/php-email-injection-attacks/

http://www.sitepoint.com/php-security-blunders/

http://php.net/manual/fr/function.mysql-real-escape-string.php