您好我希望有人可以查看我的代码,并告诉我可能导致此问题的线索,因为它让我难过。当我测试发送按钮时,一切都按照承诺发生,我得到发送的消息和重定向,但电子邮件显示所有字段,没有我输入的任何答案。这是表格:
<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"> </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"> </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"> </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"> </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);
我回顾了之前的帖子,看到大写是一个问题,所以我调查了这个并且仍然遇到了这个问题。所有其他细节对我来说都没问题......我将不胜感激任何帮助。
答案 0 :(得分:0)
您可以尝试从HTML表单中省略enctype =“text / plain”,因为这是非标准的。
但更一般地说,如果要使用它,您需要开始学习如何调试代码。调试是处理代码的一个重要部分。使用“here”文档(&lt;&lt;&lt;&lt; EOD构造)可能会产生细微的错误,因为很难发现在开始时或在EOD之前的&lt;&lt;&lt;&lt;&lt; EOD之后没有空格的要求;在末尾。
我首先尝试用其中一个字段替换最后一个语句中的“$ body”,以确保数据完全传递给脚本,如:
$success = mail($webMaster, $emailSubject, $_REQUEST['what'], $headers);