我希望只在窗口加载后显示弹出窗口,但我无法找到解决方案。 以下是源代码:
<?php
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$course = $_POST['course'];
$formcontent='<html>
<head>
<title>Message</title>
<style type="text/css">
body { background-color: lightgray;padding:20px;margin:0px auto;width:50%;border-radius:10px; }
</style>
</head>
<body>
<h2 style="color:#FAB702;text-align:center;">Thorsignia</h2>
<p><strong style="color:#000000;">Name: </strong> '.$name.'</p>
<p><strong style="color:#000000;">Phone: </strong> '.$phone.'</p>
<p><strong style="color:#000000;">Email: </strong>'.$email.'</p>
<p><strong style="color:#000000;">Course: </strong>'.$course.'</p>
</body>
</html>';
$recipient = "abc@xyz.com";
$subject = "Customer Enquiry";
$mailheader = "MIME-Version: 1.0" . "\r\n";
$mailheader .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$mailheader .= "From: $email \r\n";
if(mail($recipient, $subject, $formcontent, $mailheader)){
echo "<script>
alert('Your Message sent successfully, We will revert back to you soon, Thank you!');
window.history.go(-1);
</script>";
}else{
echo "<script>
alert('Something went wrong, check contact form again!!');
window.history.go(-1);
</script>";
}
// header('Location: ' . $_SERVER['HTTP_REFERER']);
?>
&#13;
所以我只需要在窗口加载时显示一次弹出窗口,即我需要维护会话,所以请帮助我如何维护会话。
答案 0 :(得分:0)
试试这个: 发送消息后创建会话并检查会话是否已设置。如果设置了Session,则弹出窗口并在条件中取消设置会话。 `
// check if session is not set
if(!isset($_SESSION['seesion_name'])) { `
// code here to poup the window
$_SESSION['seesion_name'] == True; // set session if popup shown once
} `