您好,我希望有人可以看一下我的代码,并为我提供一个可能导致这种情况的线索,因为它使我感到困惑。 当我测试发送按钮时,一切都按承诺进行,并且我收到了发送的消息和重定向,但是电子邮件显示了所有字段,但没有输入任何答案。 形式如下:

<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);

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

===============>>#1 票数:0 已采纳

您可以尝试从HTML表单中删除enctype =“ text / plain”,因为这是非标准的。

但是,更一般而言,如果要使用它,则需要开始学习如何调试代码。 调试是使用代码的重要部分。 使用“这里”文档(<<< EOD构造)可能会产生细微的错误,因为很难发现要求在开始<<或EOD之前<< << EOD后面不能有空格; 在末尾。

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

$success = mail($webMaster, $emailSubject, $_REQUEST['what'], $headers);

  ask by user2284733 translate from so

未解决问题?本站智能推荐: