我曾尝试查看其他相关问题,甚至向一些开发者朋友寻求帮助,但没有任何东西可以帮助我修复我的联系表。我有一个基本的 PHP 表单,但在提交时,我缺少电子邮件中的消息文本区域字段。
表格代码:
<form action="sendContactForm.php" method="post">
<div class="row">
<div class="small-12 large-12">
<div class="row formRow">
<div class="small-3 large-3 columns">
<label for="name" class="right inline">Name</label>
</div>
<div class="small-9 large-9 columns">
<input name="name" type="text" id="name" placeholder="Firstname Lastname">
</div>
</div>
</div>
</div>
<div class="row">
<div class="small-12 large-12">
<div class="row formRow">
<div class="small-3 large-3 columns">
<label for="email" class="right inline">Email</label>
</div>
<div class="small-9 large-9 columns">
<input name="email" type="text" id="email" placeholder="you@email.com">
</div>
</div>
</div>
</div>
<div class="row">
<div class="small-12 large-12">
<div class="row formRow">
<div class="small-3 large-3 columns">
<label for="company" class="right">Company Name</label>
</div>
<div class="small-9 large-9 columns">
<input name="company" type="text" id="company" placeholder="eg: Apple, Google, Microsoft">
</div>
</div>
</div>
</div>
<div class="row">
<div class="small-12 large-12">
<div class="row formRow">
<div class="small-3 large-3 columns">
<label for="description" class="right inline">Details</label>
</div>
<div class="small-9 large-9 columns">
<textarea name="description" id="description" placeholder="Please say a few words about why you are contacting me. If this is a project request, some good things to include are: project type, budget, deadline, and expected results."></textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="small-12 large-12">
<div class="row formRow">
<div class="small-12 large-9 large-offset-3 columns">
<input type="submit" name="submit" value="Submit" class="button expand"/>
</div>
</div>
</div>
</div>
</form>
PHP代码:
<?php
// from the form
$name = trim(strip_tags($_POST['name']));
$email = trim(strip_tags($_POST['email']));
$company = trim(strip_tags($_POST['company']));
$message = $_POST['message'];
$body = $name."\n".$company."\n".$message."\n";
// set here
$subject = "Contact form submitted!";
$to = 'kempfjj@gmail.com';
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
// send the email
mail($to, $subject, $body, $headers);
// redirect afterwords, if needed
header('Location: index.html');
?>
我非常感谢专业人士在这方面能给我的任何帮助。