1

您好,我希望有人可以看看我的代码,并给我一个线索,了解可能导致这种情况的原因,因为它让我很难过。当我测试发送按钮时,一切都按承诺进行,我收到了发送的消息和重定向,但电子邮件显示所有字段,而我没有输入任何答案。这是表格:

<form action="contactformprocess.php" method="post" enctype="text/plain" name="form1" id="form1">
            <p>
              <label><span class="GoldText">What is your movie about?</span> What are you trying to tell us?<span id="What">
              <textarea name="what" id="what" cols="45" rows="5"></textarea>
              <span id="countWhat">&nbsp;</span><span class="textareaRequiredMsg">Please Fill.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></label>
            </p>
            <p>
              <label>Why is this Project Important to you?  <span class="GoldText">What is it's purpose?</span><span id="why">
              <textarea name="why" cols="45" rows="5" id="why"></textarea>
              <span id="countwhy">&nbsp;</span><span class="textareaRequiredMsg">Please Fill.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></label>
            </p>
            <p>
              <label>What will people gain from watching it?<br />
              <span class="GoldText">What sentiments are we left with?</span><span id="Contribution">
              <textarea name="contribution" cols="45" rows="5" id="contribution"></textarea>
              <span id="countContribution">&nbsp;</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></label>
            </p>
            <fieldset>
              <legend>Where and when is it shot? (For dated events)</legend>
              <p>
                <label>Location:
                  <input type="text" name="location" id="location" />
                </label>
              </p>
              <p>
                <label>Date(s): <span id="EventDateStart">
                <input name="eventdatestart" type="text" id="eventdatestart" />
                <span class="textfieldInvalidFormatMsg">Invalid format.</span></span></label>
              to<span id="EventDateEnd">
              <label>
                <input name="eventdateend" type="text" id="eventdateend" />
              </label>
<span class="textfieldInvalidFormatMsg">Invalid format.</span></span>              </p>
              <p>
                <label>Time: <span id="EventTimeStart">
                <input name="eventtimestart" type="text" id="eventtimestart" />
</span></label>
              </p>
            </fieldset>
            <fieldset>
              <legend>Please tell us who you are.</legend>
              <p>
                <label>Name                </label>
                <span id="ClientName">
                <label>
                  <input type="text" name="clientname" id="clientname" />
                </label>
              <span class="textfieldRequiredMsg">Please Fill.</span></span></p>
              <p>
                <label>Phone
                  <input name="phone" type="text" id="phone" value="optional" />
                </label>
              </p>
              <p>
                <label>Email                <span id="OnlineContact">
                <input type="text" name="onlinecontact" id="onlinecontact" />
                <span class="textfieldRequiredMsg">Please Fill.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></label>
              </p>
              <p>
                <label>What other details help clarify your vision?<span id="FinalThoughts">
                  <textarea name="finalthoughts" cols="45" rows="5" id="finalthoughts"></textarea>
                <span id="countFinalThoughts">&nbsp;</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></label>
              </p>
              <p>
                <label>Send
                  <input name="button" type="submit" id="button" onclick="MM_validateForm('clientname','','R','phone','','NisNum','onlinecontact','','RisEmail','what','','R','why','','R');return document.MM_returnValue" value="Send" />
                </label>
              </p>
            </fieldset>
          </form>

这是php:

/* Email Variables */
$emailSubject = 'contactformprocess'; /*Make sure this matches the name of your file*/
$webMaster = 'wavelengthfredy@gmail.com';

/*design by Mark Leroy @ http://www.helpvid.net*/

/* Data Variables */
$what = $_REQUEST['what'];
$why = $_REQUEST['why'];
$contribution = $_REQUEST['contribution'];
$location = $_REQUEST['location'];
$eventdatestart = $_REQUEST['eventdatestart'];
$eventdateend = $_REQUEST['eventdateend'];
$eventtimestart = $_REQUEST['eventtimestart'];
$clientname = $_REQUEST['clientname'];
$phone = $_REQUEST['phone'];
$onlinecontact = $_REQUEST['onlinecontact'];
$finalthoughts = $_REQUEST['finalthoughts'];



$body = <<<EOD
<br><hr><br>
What: $what <br>
Why: $why <br>
Contribution: $contribution <br>
Location: $location <br>
EventDateStart: $eventdatestart <br>
EventDateEnd: $eventdateend <br>
EventTimeStart: $eventtimestart <br>
ClientName: $clientname <br>
Phone: $phone <br>
OnlineContact: $onlinecontact <br>
FinalThoughts: $finalthoughts <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);

我查看了之前的一篇文章,发现大写是一个问题,所以我研究了一下,仍然遇到了这个问题。所有其他细节对我来说都很好......我将不胜感激。

4

1 回答 1

0

您可以尝试从 HTML 表单中省略 enctype="text/plain",因为这是非标准的。

但是,更一般地说,如果要使用它,您需要开始学习如何调试代码。调试是处理代码的重要部分。使用“here”文档(<<<EOD 结构)可能会产生细微的错误,因为很难发现在开始时 <<<EOD 之后或 EOD 之前没有空格的要求;在末尾。

我会首先尝试用一个字段替换最后一条语句中的“$body”,以确保数据完全传递给脚本,如下所示:

$success = mail($webMaster, $emailSubject, $_REQUEST['what'], $headers);
于 2013-04-16T02:57:21.433 回答