I am using this query on pageload but i want to run it only once not even on page refresh , although I used header() but still getting error
"Cannot modify header information - headers already sent by (output started at "C:\storev\header.php:149) in storev\checkout.php on line 124.) line
$insertquery= "INSERT INTO cart ".
"(session_id,pro_id, prod_name,prod_price,prod_image) "."VALUES ".
"('$sid','$productid','$productname','$productprice','$productimage')";
$insertresult=mysqli_query($con,$insertquery);
$cartquery="SELECT *,COUNT(pro_id) AS ID,SUM(prod_price) AS Sum FROM cart WHERE session_id='" . $_SESSION['session'] . "' GROUP BY pro_id " ;
$cartresult=mysqli_query($con,$cartquery);
header('LOCATION:checkout.php');
kindly tell some other way like inserting only once then even on page refresh it does not insert I dont want to do header() thing. I am passing productid in url through which Insert query runs