2014-05-08 25 views
0

我在我的網站上發送了一封發送到我的電子郵件的表單。除了拒絕使用作爲文本區域的「描述」字段之外,其效果很好。我嘗試了各種各樣的東西。我是一個前端開發人員,所以我沒有PHP的許多知識......PHP文件發送我的表單除了「textarea」之外的所有內容

<div class="form"> 
        <FORM METHOD="POST" ACTION="projectplanner.php"> 
         <div class="form-spacing"> 
         <INPUT TYPE="text" NAME="name" SIZE="30" placeholder="First & Last name" id="form-font"> 
         </div> 
         </br> 
         <div class="form-spacing"> 
         <INPUT TYPE="text" NAME="email" SIZE="30" placeholder="Email Address" id="form-font"> 
         </br> 
         </div> 
         <div class="form-spacing"> 
         <INPUT TYPE="text" NAME="TimeZone" SIZE="30" placeholder="Time Zone" id="form-font"> 
         </div> 
         </br> 
         <div class="form-spacing"> 
         <INPUT TYPE="text" NAME="Location" SIZE="30" placeholder="Location" id="form-font"> 
         </div> 
         <br> 
         <div class="form-spacing"> 
         <textarea rows="10" cols="90" NAME="description" placeholder="Briefly describe what you are looking for." id="form-font"></textarea> 
         </div> 
         <br> 
         <div class="form-spacing"> 

         <INPUT TYPE="text" NAME="Budget" SIZE="30" placeholder="Enter your budget for the website" id="form-font"> 
         </div> 
         </br> 
         <a href="sent.html"> 


         <div class="form-submit"> 

         <INPUT TYPE="submit" > 
         </div> 
         </a> 
        </FORM> 
        </div> 

和我的PHP代碼..

<?php 
/* Set e-mail recipient */ 
$myemail = "REMOVED FOR PRIVACY"; 

/* Check all form inputs using check_input function */ 
$name = check_input($_POST['name'], "Enter your name"); 
$subject = check_input($_POST['Budget'], "Enter a budget"); 
$email = check_input($_POST['email']); 
$comment = check_input($_POST['description']); 

/* If e-mail is not valid show error message */ 
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) 
{ 
show_error("E-mail address not valid"); 
} 
/* Let's prepare the message for the e-mail */ 
$message = " 

Name: $name 
E-mail: $email 
Budget: $subject 

Message: 
$description 

"; 

/* Send the message using mail() function */ 
mail($myemail, $subject, $message); 

/* Redirect visitor to the thank you page */ 
header('Location: thankyou.html'); 
exit(); 

/* Functions we used */ 
function check_input($data, $problem='') 
{ 
$data = trim($data); 
$data = stripslashes($data); 
$data = htmlspecialchars($data);  
if ($problem && strlen($data) == 0) 
{ 
show_error($problem); 
} 
return $data; 
} 

function show_error($myError) 
{ 
?> 
<html> 
<body> 

<p>Please correct the following error:</p> 
<strong><?php echo $myError; ?></strong> 
<p>Hit the back button and try again</p> 

</body> 
</html> 
<?php 
exit(); 
} 
?> 
+0

檢查使用Chrome開發者工具或Firebug的 – zerkms

回答

9

您存放在變量的描述稱爲$comment。然後嘗試在$description之後引用它。你所尋找的,我相信是這樣的:

Message: 
$comment 
+0

我的上帝什麼實際發送,我現在感覺這麼愚蠢。謝謝,它已被修復:) – user3317455

+0

有時一雙額外的眼睛幫助:) – bansi

+0

哈,我們都做到了。 –

相關問題