当您单击发送时,会弹出一个窗口,说明是否发送成功。这就是我想要发生的一切,但此时弹出窗口出现并且在用户按下的窗口中发送它进入操作调用的 php 页面,我如何停止该窗口进入 php 页面并且只是有弹出窗口出现?
表格代码:
<form method="post" class="contact-form" action="php/callback.php" >
<input name="name" type="text" id="formbox" value="Name" onfocus="(this.value == 'Name') && (this.value = '')" onblur="(this.value == '') && (this.value = 'Name')"/><br />
<input name="number" type="text" id="formbox" value="Number" onfocus="(this.value == 'Number') && (this.value = '')" onblur="(this.value == '') && (this.value = 'Number')"/><br />
<input type="submit" value="Send" id="formbutton">
</form>
php代码:
<?php
$name = $_POST['name'];
$number = $_POST['number'];
$to = "email@email.co.uk";
$subject = "Call Back Enquiry";
$message = "Hi Raymond, someone that came to your website wants you to call them back, their name is '$name' and their number is '$number'";
$from = "Your Website";
$headers = "From:" . $from;
$send_contact = mail($to,$subject,$message,$headers);
if($send_contact){
echo "<script>alert('We will contact you shortly');</script>";
}
else {
echo "<script>alert('Something went wrong, try again!');</script>";
}
?>