1

喜欢这个网站,这是我在这里的第一个问题。我是 php 编程新手。我在表单所在的默认页面上有以下编码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mill City Cannabis</title>
</head>

<body bgcolor="#000000">
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
  <tr>
    <td>
        <center>
          <img src="Images/mccBanner.jpg" width="900" height="320" alt="Mill City Cannabis" />
        </center>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>
      <table width="1000">
        <tr>
          <td width="400">&nbsp;</td>
          <td>
            <form action="thankyou.php" name="feedback">
            <label>
              <font face="Tahoma" color="#00FF00" size="2">Name:</font>
            </label><br />
            <input type="text" name="name" style="font-size:10px font:Tahoma border-color:#0F0" required="required" /><br />
            <label>
              <font face="Tahoma" color="#00FF00" size="2">Email:</font>
            </label><br />
            <input type="email" name="email" required="required" /><br /><br />
            <label>
              <font face="Tahoma" color="#00FF00" size="2">What would you like to see as content here @ Mill City Cannabis:</font><br />
            </label>
            <textarea name="content" required="required"></textarea><br />
            <br />
            <input type="submit" name="submit" id="submit" value="Submit" />
            <input type="reset" name="reset" id="reset" value="Reset" />
            </form>
          </td>
          <td width="400">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>

当它呈现到“thankyou.php”页面时,这就是我的“thankyou.php”页面中的内容:

<?php

##############################
#                            #
# Coded By: Joshua Martinez  #
# MrJoshuaMartinez@gmail.com #
#                            #
##############################

/* Subject and Email variables */

$emailsubect = "Feedback";
$webMaster = "millcitycannabis@gmail.com";

/* Gathering Data Variables */

$namefield = $_POST['name'];
$emailfield = $_POST['email'];
$contentfield = $_POST['content'];

$body = <<<EOD
<br><hr><br>
Name: $namefield <br>
Email: $emailfield <br>
Feedback: $contentfield <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailsubect, $body, $headers);

/* Results rendered as HTML */

$theResults = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mill City Cannabis</title>
</head>

<body bgcolor="#000000">
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
  <tr>
    <td>
    <center>
      <img src="Images/mccBanner.jpg" width="900" height="320" alt="Mill City Cannabis" />
    </center>
    </td>
  </tr>
  <tr>
    <td height="50">&nbsp;</td>
  </tr>
  <tr>
    <td align="center">
<font face="tahoma" size="2" color="#00FF00">
      Thank You For Your Feed Back!<br />
      Please check back soon with us!
    </font>
    </td>
  </tr>
  <tr>
<td align="center">
      <font face="tahoma" size="1" color="#00FF00">© All Rights Reserved</font> 
      <font face="tahoma" size="1" color="#FFFFFF">Mill City Cannabis </font>
      <font face="tahoma" size="1" color="#00ff00">2015</font>
</table>
</body>
</html>
EOD;
echo "$theResults";
?>

最后,当发送电子邮件时,出现的只是:

空白未知发件人

姓名:(空白)
电子邮件:(空白)
反馈:(空白)

4

2 回答 2

0
<form action="thankyou.php" name="feedback">

请在此处提及方法类型

<form action="thankyou.php" name="feedback" method="post">
于 2015-04-10T05:02:00.620 回答
0

您尚未指定表单方法。

默认情况下,表单方法是 GET ,在您的 php 代码中,您尝试从 POST 获取值。

于 2015-04-10T05:02:01.750 回答