【发布时间】:2014-04-21 13:41:39
【问题描述】:
我按照教程制作了一个联系表。也将其上传到 wamp 以进行测试。但是我仍然不断收到错误,但我真的无法找到错误所在。也许是因为我不知道 PHP。有人可以检查我的代码并让我知道问题所在。我相信这个问题很小。谢谢。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="index.css">
<title>Contact Form</title>
</head>
<body>
<header class="body">
</header>
<section class="body">
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: TangledDemo';
$to = 'aijaz@techanipr.com';
$subject = 'Hello';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
<form method="post" action="index.php">
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<input id="submit" placeholder="Type Here" name="Submit" type="submit" value="Submit">
</form>
</section>
<footer class="body">
</footer>
</body>
</html>
【问题讨论】:
-
请注意,因为您似乎是 php 新手以及如何创建邮件:请花点时间告诉自己有关联系表格的陷阱是什么。例如。您需要注意它不能用于提交垃圾邮件。