我的网站有一个使用HTML和PHP的联系表单。当用户按下发送按钮时,它进入成功页面。如何将此更改为与联系表单在同一页面上的弹出消息?这是我的代码:
<section id="contact" class="main style3 blue">
<div class="content container">
<header>
<h2>Say Hello.</h2>
<p>You can use the form below to contact us regariding any form of inquiry</p>
</header>
<div class="box container 75%">
<!-- Contact Form -->
<form action="mail.php" method="POST">
<div class="row 50%">
<div class="6u 12u(mobile)"><input type="text" name="name" placeholder="Name" /></div>
<div class="6u 12u(mobile)"><input type="email" name="email" placeholder="Email" /></div>
</div>
<div class="row 50%">
<div class="12u"><textarea name="message" placeholder="Message (Please include your telephone number)" rows="6"></textarea></div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
<li><input type="submit" value="Send Message" /></li>
</ul>
</div>
</div>
</form>
</div>
</div>
</section>
PHP:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent = " From: $name \n Phone: $phone \n Message: $message \n Email: $email";
$recipient = "email@email.com";
$subject = "Message from the Site";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='/1/' style='text-decoration:none;color:#ff0099;'><strong> Return Home</strong></a>";
?>