我尝试了很多解决方案,以确保我是否可以找到解决方案而不发布此内容,但所有解决方案都太旧而且没有帮助。
我的网站上有一个用于查询表单的登录页面弹出窗口,其中模式弹出窗口打开并且用户填写表单。我现在唯一想要的是在用户提交表单后自动关闭弹出窗口。
我试过这个:
<?php
$your_email ='user@gmail.com';
if(isset($_POST['submit1']))
{
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$mobile = $_POST['mobile'];
//$user_message = $_POST['message'];
///------------Do Validations-------------
if(empty($errors))
{
//send the email
$to = $your_email;
$subject="Enquiry from website";
$from = $your_email;
$body = "A user $name submitted the contact form For your website:\n".
"Name: $name\n".
"Email: $visitor_email \n".
"Contact No: $mobile \n";
//"Message: $user_message\n\n";
$headers = "From: $from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to, $subject, $body,$headers);
echo "<script>alert('Thanks! for contacting us. We will get back to you within 24 hours.');</script>";
//header('Location: contact');
}
}
?>
使用Javascript:
<script language="JavaScript" type="text/javascript">
function CloseAndRefresh()
{
opener.location.reload(true);
self.close();
}
</script>
HTML:
<form class="contactForm" method="post">
<table width="100%" border="0">
<tbody>
<tr>
<td>Name</td>
<td>
<input id="name" name="name" type="text" placeholder="Name">
</td>
</tr>
<tr>
<td>Email</td>
<td>
<input name="email" type="text" id="email" placeholder="Email ID">
</td>
</tr>
<tr>
<td>Mobile</td>
<td>
<input name="mobile" type="text" maxlength="10" id="mobile" placeholder="Mobile No">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit1" value="Submit" onClick="CloseAndRefresh(); return:true;" id="btnsubmit" class="agree button">
</td>
</tr>
</tbody>
</table>
</form>
请给我一个解决方案。