当用户在首页上单击后退按钮时,我在会话中设置了值会话变量也随之设置

if(isset($_SESSION['Seats']))
{
    $Eventid = $_SESSION['Eventid'];
    $stmt = $con->prepare(
        'UPDATE fistevent SET `Status`=" " where `Event_Id`=? AND `seats`=? AND `Status`="Hold" '
    );
    $stmt->bind_param(
         "st",$_SESSION['Eventid'],
          $_SESSION['Seats']
    );
    $stmt->execute();
    session_destroy();
    session_unset();
}


这些值是通过POST方法来自其他页面的

if(isset($_POST['EventId']))
        {
        $Price=mysqli_real_escape_string($con,$_POST['Price']);
        $TicketType=mysqli_real_escape_string($con,$_POST['TicketType']);
        $EventId=mysqli_real_escape_string($con,$_POST['EventId']);
        }
        $stmt = $con->prepare("select * from fistevent WHERE  row_name LIKE 'A%'");
        $stmt->bind_param("s", $_POST['EventId']);
        $stmt->execute();
        $result = $stmt->get_result();
        $numRows = $result->num_rows;
        if($numRows > 0) {
        echo '<ul id="sub" class="sub">';
       while($r = $result->fetch_assoc()) {
**displaying vlaues here came from database**

}
        else
        {
            echo "No seats Available";
        }

最佳答案

考虑一下浏览器缓存。

后退按钮加载页面的缓存版本。

尝试设置此代码,可能对您有帮助

<?php
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");
?>

关于javascript - 如何在浏览器上单击“后退”按钮并刷新页面后重新更新查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44062038/

10-16 15:15