2016-02-18 101 views
0

我希望彈出窗口只在窗口加載後顯示,但iam無法找到解決方案。 下面是源代碼:會話彈出窗口

<?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> 
 
\t <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 = "[email protected]"; 
 
$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)){ 
 
\t 
 
\t echo "<script> 
 
      alert('Your Message sent successfully, We will revert back to you soon, Thank you!'); 
 
      window.history.go(-1); 
 
    </script>"; 
 
\t 
 
}else{ 
 
\t 
 
\t echo "<script> 
 
      alert('Something went wrong, check contact form again!!'); 
 
      window.history.go(-1); 
 
    </script>"; 
 
} 
 

 

 
// header('Location: ' . $_SERVER['HTTP_REFERER']); 
 

 
?>

所以我只需要在彈出的窗口中加載要顯示一次,這是我需要保持會話,所以請幫助我如何維護會話。

回答

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 
} `