【发布时间】:2013-11-30 01:28:30
【问题描述】:
我创建了一个联系页面和一个单独的 PHP 页面来接收发布的数据。我想让 PHP 在弹出窗口中打开。我在网上试过方法都没有成功,我可以让弹出窗口出现,但我不能让 PHP 发送数据。
<!------Contact Page------->
<form method='post' action='sendemail.php' >
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" placeholder="Type Here" id="email">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<label>Human Verification</label>
<input name="human" placeholder="2 + 2 = ? " id="human">
<input id="submit" name="submit" type="submit" value="Submit">
</label>
</form>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = $email;
$to = 'my@email.com';
$subject = 'New Message';
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<h4>Your message has been sent!</h4>';
} else {
echo '<h4>Something went wrong, go back and try again!</h4>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<h4>You answered the anti-spam question incorrectly!</h4>';
}
} else {
echo '<h4>You need to fill in all required fields!!</h4>';
}
}
?>
【问题讨论】:
-
你有什么错误吗?
-
第一行是
sendeail.php,而不是sendemail.php,并且您在另一个<form>中有一个<form>,这是无效的。
标签: javascript jquery forms php