这就是所谓的sendmail.php一个验证并将从接触形式的电子邮件(其中包含如下)PHP文件停止页面重定向到php脚本文件提交表单时
我有麻烦的是,当该警报被点击它重定向到sendemail.php,因为,我假设,形式的行动= sendmail.php
我该如何解决这个问题,因此它留在联系页面上,用户可以拿起他们的地方离开?我曾尝试使用标题为感谢页面,但无济于事!
if (isset($_POST["submit"])) {
$validate = validateInput($_POST["name"], $_POST["message"], $_POST["subject"]);
if ($validate==FALSE) {
$error_msg = "Please fill out all information";
echo '<script type="text/javascript">
alert("'.$error_msg.'");
</script>';
} else {
$mailcheck = spamcheck($_POST["email"]);
if ($mailcheck==FALSE) {
$error_msg = "Invalid email address";
echo '<script type="text/javascript">
alert("'.$error_msg.'");
</script>';
} else {
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$subject = $_REQUEST['subject'] ;
mail("[email protected]", $subject, $message, "From: $email");
header("Location: http://www.thankyou.html");
}
}
}
<form method="post" action="sendmail.php">
<input type="text" name="name" maxlength="50" placeholder="Name" class="contact-standard" /></br></br>
<input type="email" name="email" placeholder="Email" class="contact-standard"></input></br></br>
<input type="text" name="subject" placeholder="Subject" class="contact-standard"></input></br></br>
<textarea name="message" placeholder="Message" class="contact-message"></textarea></br></br>
<input type="submit" name="submit" value="Send Message" class="contact-submit"></input></br></br>
</form>
只是在这个页面上发生了一切。将代码从'sendmail.php'移到此页面(或在提交时包含)。 – Rasclatt 2014-09-27 04:10:37
成功后在'sendmail.php'中使用头文件 – 2014-09-27 04:12:37
Arif - 我试过这个,但是我只是一直重定向到sendmail.php。标题为成功工作,但由于某种原因没有验证错误 – 2014-09-27 04:14:50