我的网站上有一个表格发送到我的电子邮箱。效果很好,除了它拒绝使用字段"描述"这是一个文本区域。我尝试过各种各样的事情。我是一名前端开发人员,所以我不太了解PHP ...
<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 :(得分:9)
您将描述存储在名为$comment
的变量中。然后尝试将其引用为$description
。你在寻找什么我相信是这样的:
Message:
$comment