我正在尝试创建一个循环,在满足条件时重定向到另一个脚本。但此刻,它满足条件,结束循环,但不重定向到脚本。我没有做过任何工作...
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
define('INCLUDE_CHECK',true);
require '../config/connection.php';
session_name('ppRemember');
session_set_cookie_params(86400);
session_start();
//get value from database. if is pending then display loading else display summary. if is complete but no session set say session has expired
if (isset($_SESSION['txnId'])) {
if ($_SESSION['txnId']==true) {
header('Location: ../confirmation');
die();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="basket-empty" title="Success" style="display:none;">
<p>Basket emptied</p>
</div>
<div id="confirm-empty" title="Confirm" style="display:none;">
<p>Are you sure you want to empty your basket?</p>
</div>
<div id="page-wrapper">
<div id="page">
<div id="header" class="without-secondary-menu">
<div class="section clearfix">
<div id="logo-caption">
<a href="/" title="Home" rel="home" id="logo">
</a>
</div>
<div id="caption">
</div>
<div id="main-menu" class="navigation">
<ul id="main-menu-links" class="links clearfix">
<li class="menu-2 active-trail active"><a href="../index"> Order Online </a></li>
<li class="menu-9"><a href="../my-account"> My Account </a></li>
<?php if (!$_SESSION['id']) {?>
<li class="menu-10"><a href="../login"> Sign In </a></li>
<?php } ?>
<li class="menu-5"><a href="../getaquote"> Get a Quote </a></li>
<li class="menu-6"><a href="../contactus"> Contact Us </a></li>
<li class="menu-11"><a href="../news"> News </a></li>
<li class="menu-8"><a href="../uploads"> Uploads </a></li>
<li class="menu-7"><a href="../downloads"> Downloads </a></li>
</ul>
</div>
</div>
</div>
<?php if (isset($_SESSION['id'])) { ?>
<div id="panel" class="clearfix">
<div id="account-links">
<ul class="username">
<li><span class="account-links"><a href="../my-account">You are logged in as <b><?php echo $_SESSION['username']; ?></b></a></span>
<span class="logout"><a href="../destroy">Logout</a></span></li>
</ul>
</div>
</div>
<?php } ?>
<div id="main-wrapper" class="clearfix">
<div id="main" class="clearfix">
<div class="content">
<a id="main-content"></a>
<div class="tabs">
</div>
<div class="region region-content">
<div id="block-system-main" class="block block-system">
<div class="content">
<div id="node-1" class="clearfix">
<div class="content clearfix">
<?php if (!isset($_SESSION['txnId'])) {
if (isset($_SESSION['cart'])) { ?>
<div class="loading2" style="height:300px;">
<span class="text2"><font size="6pt"><b>Loading....</b></font></span>
<img src="../images/ajax-loader2.gif"/><br />
<font size="3pt"><b>Please wait a moment whilst we process your payment</b></font><br />
<font size="1pt"><b>Click <a href="/order/complete">here</a> to reload after 10 seconds</b></font>
</div>
<?php }
} ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="footer-wrapper">
<div class="section">
<div id="footer" class="clearfix">
<div class="region region-footer">
<div class="block">
<div class="content">
<div class="column1">
</div>
<div class="column2">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
$trans = $_SESSION['transaction_id'];
$clientId = $_SESSION['id'];
if (!isset($_SESSION['txnId'])){
while ($_SESSION['txnId']!=true) {
$mysqli = new mysqli("localhost", "#####", "#####", "######");
$stmt = $mysqli->prepare("SELECT `txn_id` FROM `trans` AS t, `order_table` AS ot, `customer_order_details` AS cod WHERE t.transaction_id=?
&& t.transaction_id = ot.transaction_id && ot.customer_order_details_id = cod.customer_order_details_id && cod.client_id=?");
$stmt->bind_param('ii',$trans,$clientId);
if ($stmt->execute()) {
$stmt->store_result();
$num_rows = $stmt->num_rows;
if ($num_rows>=1) {
$stmt->bind_result($txnidrow);
$stmt->fetch();
$stmt->free_result();
$stmt->close();
$_SESSION['CARRYTXNID'] = $txnidrow;
$_SESSION['txnId'] = true;
}
}
}
}
header('Location: ../confirmation');
die();
}
?>
非常感谢任何进展。我尝试了一个 do while 循环,没有死亡/退出的标题。我已经删除了所有代码并自行重定向了页面,运行了脚本,一切都很好。等等,等等。我附和了一些东西以确保最终满足条件。