这是我在这里的第一个问题,我是 PHP 初学者,一直盯着这段代码试图找到错误,但我就是无法理解。
电子邮件联系表格:
<div id="newsletter">
<h1>Contact Us</h1>
<form method="post" action="global.footer.php">
<p><input id="one" name="name" placeholder="name"></p>
<p><input id="two" name="email" placeholder="email"></p>
<p><textarea id="three" name="message" placeholder="type message here..."></textarea></p>
<p><input id="submit" type="submit" name="submit" value="Submit"></p>
</form>
</div>
脚本:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: TangledDemo';
$to = 'danajwright@gmail.com';
$subject = 'Hello';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
?>
<?php
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, please try again.</p>';
}
} else {
echo '<p>You need to fill in all required fields!!</p>';
}
?>
任何帮助,将不胜感激!