我的网站是一个带有导航的寻呼机,它链接到同一文档中页面的不同部分。所以我的联系方式是 stie.com/#contact 而不是 site.com/contact.html
我使用链接到 mail.php 的 post 方法以 html 编码我的联系表格。点击提交按钮后,我被重定向到 site.com/mail.php,其中显示“您的消息已成功发送”。由于我没有contact.html文件可以转换为contact.php并将php代码放在我希望显示成功消息的位置,因此如何获取它以使其显示在联系表单的顶部?
<div class="row">
<div class="12u">
<form method="post" action="mail.php">
<div>
<div class="row half">
<div class="6u">
<input type="text" name="name" id="name" placeholder="Name" />
</div>
<div class="6u">
<input type="email" name="email" id="email" placeholder="Email" />
</div>
</div>
<div class="row half">
<div class="12u">
<input type="text" name="subject" id="subject" placeholder="Subject" />
</div>
</div>
<div class="row half">
<div class="12u">
<textarea name="message" id="message" placeholder="Message"></textarea>
</div>
</div>
<div class="row">
<div class="12u">
<a href="#" class="button form-button-submit">Send Message</a>
<a href="#" class="button button-alt form-button-reset">Clear Form</a>
</div>
</div>
</div>
</form>
</div>
我的邮件.php
<?php
//GET INFO FROM CONTACT FORM
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST ['subject'];
$message = $_POST['message'];
$from .= $_POST ['email'];
$to = 'email@site.com';
// compose headers
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
//POST SUBMIT
if ($_POST['sumbit']);
if ($name != '' && $subject != '' && $message !='' && $email != '') {
if (mail ($to, $subject, $from, $message, $headers)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else {
echo '<p>Please fill in all required fields!!</p>';
}
?>