2014-05-08 24 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

哈,我们都做到了。 –

相关问题