我知道这有点重复,但我现在已经阅读了两天的答案,并尝试了几种解决方案,我的问题仍然存在。我检查了空格,我已经在每个页面的开头添加了ob_start()。我已经通过数据库打开更改为每页包含的标题。我应该尝试将ob_end_flush()或ob_end_clean()包含在标题中吗?我真的需要一些指导,我有很多页面提供类似的功能,我得到的一些页面根本不会重定向到新的标题位置。请帮助,我是一个新的PHP程序员,这是我的第一个学期,所以我意识到还有很多其他的错误,比如不安全的sql语句,但我需要这个工作请。
<?php
ob_start();
session_start();
include('includes/FireHeader.php');
?>
<!doctype html>
<html lang=en>
<head>
<title>Added In State Item</title>
<meta charset=utf-8>
<link rel="stylesheet" type="text/css" href="css/fireworks.css">
</head>
<body>
<?php
if (isset($_SESSION['user_id'])){
$user_id = $_SESSION['user_id'];
}
if(isset($_POST['ip_id'])) {
$ip_id = $_POST['ip_id'];
}
if(isset($_POST['orderIn_quantity'])) {
$orderIn_quantity = $_POST['orderIn_quantity'];
}
$display="SELECT *
FROM in_product WHERE ip_id = '$ip_id'; " ;
$displayResult = @mysqli_query($dbhandle, $display)
or die (mysqli_error($dbhandle));
$row = mysqli_fetch_array($displayResult);
$ip_name = $row['ip_name'];
$ip_image = $row['ip_image'];
$ip_desc = $row['ip_desc'];
$ip_price = $row['ip_price'];
$ip_stock = $row['ip_stock'];
$orderIn_total = $row['ip_price'] * $orderIn_quantity;
$orderIn_paid = "No";
$insert = "INSERT INTO order_instate(user_id, ip_id, orderIn_quantity, orderIn_total, orderIn_paid, orderIn_date )
VALUES ('$user_id', '$ip_id', '$orderIn_quantity', '$orderIn_total', '$orderIn_paid', CURDATE() )";
$addInsert=mysqli_query($dbhandle, $insert)
or die(mysqli_error($dbhandle));
if ($addInsert == NULL) {
echo "<h3>There was a Problem adding this item. </h3>";
} else {
echo "<h3>This Item was Added to Your Cart. </h3>";
$new_stock =0;
$new_stock = $ip_stock - $orderIn_quantity;
$changeVals="UPDATE in_product
SET ip_name = '$ip_name', ip_desc = '$ip_desc', ip_price = '$ip_price', ip_stock = '$new_stock', ip_image = '$ip_image'
WHERE ip_id = '$ip_id'; " ;
$changeCheck=mysqli_query($dbhandle, $changeVals)
or die(mysqli_error($dbhandle));
if (mysqli_affected_rows($dbhandle) == 0) {
echo "<span class = 'errorlog'>The product stock was not updated.</span>";
}
}
?>
<br><br>
<p class="middle">
<a href='instate.php' id='shoppin'>
<input type="button" name="contshop" value="Continue Shopping" style="width: 162px; height: 37px" >
</a>
</p>
<p class="middle">
<a href='cart.php' id='checkout'>
<input type="button" name="cart" value="View Shopping Cart" style="width: 162px; height: 37px" >
</a>
</p>
</body>
</html>