-1
當前我的聯繫表單在提交時顯示thankyou聯繫我們的提醒,但我想讓它做的是謝謝您以彈出窗口或屏幕上的文字聯繫我們,任何地方,說聲謝謝,但只是在同一頁的接觸形式聯繫方式感謝頁面
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = ' [email protected]';
$subject = 'Message from a site visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact_page.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to [email protected]');
window.location = 'contact_page.html';
</script>
<?php
}
?>
<form action="contact.php" style="height:auto;" class="form" method="post">
<h1>Your name</h1>
<input type="text" class="form textbox" name="cf_name"><br>
<h1>Your e-mail</h1>
<input type="text" class="form textbox" name="cf_email"><br>
<h1>Message</h1>
<textarea class="form textbox" name="cf_message"></textarea><br>
<input type="submit" value="Send">
我試圖取代if語句
if ($mail_status) { ?>
<div><h1>thank you for submitting the contcat form</h1> </div>
<?php
}
但是,這仍然去到另一個頁面
這是要廣泛回答在這裏完全,但你需要看看Ajax/JavaScript來subtmit你的形式和處理結果。 – jeroen