<!doctype html>
<?php
ob_start(); 

// Check if the current page is successfulpayment.php
$currentScript = basename($_SERVER['SCRIPT_NAME']);

if ($currentScript === 'successfulpayment.php') {
    // This block will only execute if the current page is successfulpayment.php
    
    if (isset($_POST["oid"])) {
        $oidFromBank = $_POST["oid"];
        
        // Query to fetch user_id based on tracking_no from the database
        $query = "SELECT user_id FROM orders WHERE tracking_no = '$oidFromBank'";
        
        // Assuming you have a database connection $con
        $result = mysqli_query($con, $query);
        
        if ($result) {
            // Check if any rows were returned
            if (mysqli_num_rows($result) > 0) {
                // Fetch the row
                $row = mysqli_fetch_assoc($result);
                
                // Check if 'user_id' exists in the fetched row
                if (isset($row['user_id'])) {
                    // Start a session
                    session_start();
                    
                    // Set the user_id in the session
                    $_SESSION['auth_user']['user_id'] = $row['user_id'];
                    
                    // Free the result set
                    mysqli_free_result($result);
                } else {
                    echo "User ID not found in the database for tracking number: $oidFromBank";
                }
            } else {
                echo "No matching order found for tracking number: $oidFromBank";
            }
        } else {
            echo "Error executing database query: " . mysqli_error($con);
        }
    } else {
        echo "Order ID (oid) not received from bank.";
    }
}
?>
<html lang="en">

  <head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="description" content="">

    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">

    <meta name="generator" content="Hugo 0.84.0">

    <title>Exelsior Hotels</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/5.0/examples/starter-template/">

    <link rel="preconnect" href="https://fonts.googleapis.com">

<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<link href="assets/css/app.css" rel="stylesheet">

    <!-- Bootstrap core CSS -->

<link href="assets/dist/css/bootstrap.min.css" rel="stylesheet">

    <style>

      .bd-placeholder-img {

        font-size: 1.125rem;

        text-anchor: middle;

        -webkit-user-select: none;

        -moz-user-select: none;

        user-select: none;

      }



      @media (min-width: 768px) {

        .bd-placeholder-img-lg {

          font-size: 3.5rem;

        }

      }

    </style>

    <!-- Custom styles for this template -->

    <link href="assets/dist/css/starter-template.css" rel="stylesheet">

    <link href="assets/dist/css/app.css" rel="stylesheet">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">



  <!-- alertify css -->

  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css"/>

  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/bootstrap.min.css"/>

  </head>

  <body>
    <?php
          $currentScript = basename($_SERVER['SCRIPT_NAME']);

        if ($currentScript === 'successfulpayment.php') {
            // This block will only execute if the current page is successfulpayment.php
            ?>
            <nav class="navbar navbar-expand-lg navbar-light shadow sticky-top bg-white">
              <div class="container mobilenavbarwrap">
                <a class="navbar-brand" href="index.php">
                  <img class="img-fluid" src="assets/img/logo.png" width="70%" alt="logo">
                </a>
                <a href="my-orders.php" class="btn btn-primary float-end" style="width:100%;color:#fff!important;">My Orders</a>
              </div>
            </nav>
            <?php
        }else{
     include('navbar.php');
   }?>

    <main>

    <?php
ob_end_flush(); 
?>