【问题标题】:Session popup window会话弹出窗口
【发布时间】:2016-05-30 04:18:40
【问题描述】:

我希望仅在窗口加载后才显示弹出窗口,但我无法找到解决方案。 以下是源代码:

<?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']);

?>

所以我只需要在窗口加载时显示一次弹出窗口,即我需要维护一个会话,所以请帮助我如何维护会话。

【问题讨论】:

    标签: javascript php jquery html


    【解决方案1】:

    试试这个: 发送消息后创建会话并检查会话是否设置。如果设置了会话,则弹出窗口并在条件中取消设置会话。 `

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

    【讨论】:

      猜你喜欢
      • 2011-02-25
      • 1970-01-01
      • 1970-01-01
      • 2012-01-04
      • 1970-01-01
      • 2010-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多