2013-04-16 243 views
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 = '[email protected]'; 

/*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

您可能會嘗試從HTML表單中刪除enctype =「text/plain」,因爲這是非標準的。

但是,更普遍的是,如果你要使用它,你需要開始學習如何調試代碼。調試是使用代碼的一個重要部分。使用「這裏」文檔(EOD構造)可以創建細微的錯誤,因爲難以發現要求在EOD開始或之前沒有空白空間;最後。

我第一次嘗試在最後一條語句替換爲「$體」的領域之一,以確保數據得到傳遞給腳本所有的,因爲在:

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

改變了entype現在正在取得成果。 – user2284733

+0

我忽略了那個。我長期盯着這段代碼,衷心感謝! – user2284733

+0

您應該將答案標記爲已接受,所以其他人也會覺得這很有用。 –

相關問題