Jump to content

I need to stop things from duplicating the insert


JLitkie

Recommended Posts

I need to stop things from duplicating the insert of products into a table on refresh.  Im stumped!

 

This is the insert page that forwards to the display page.

 

<?php

session_start();

$UserID = session_id();

$SKU = $_POST['SKU'];
$QTY = $_POST['QTY'];

include("database.php");

mysql_select_db("brandysbeanies", $con);

$result = mysql_query("SELECT * FROM Products WHERE SKU='$SKU'");

while($row = mysql_fetch_array($result))
{

$Name = $row[1];
$Image1 = $row[4];
$Image2 = $row[17];
$Image3 = $row[18];
$Image4 = $row[19];
$Description = $row[3];
$Cost = $row[5];
$Price = $row[6];
$Ship = $row[9];
$Option1 = $row[10];
$Option2 = $row[11];
$Option3 = $row[12];
$Option4 = $row[13];
$Option5 = $row[14];

}

$time_1 = strtotime("now");
                
$today_date = date("ymd",$time_1);
$today_time = date("his",$time_1);

$Total = $Price * $QTY;
$Shipping = $Ship * $QTY;
$ID = "$today_date$today_time";

include("database.php");

mysql_select_db("brandysbeanies", $con);

$sql="INSERT INTO productorders (ClientID,OrderID,Productname,Productdescription,Cost,Price,Quantity,Shipping,Total,Photo)
              VALUES ('$UserID','$ID','$Name','$Description','$Cost','$Price','$QTY','$Shipping','$Total','$Image1')";
  
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

include("cart.php");

?>

 

This is the display page.

 

<!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" xml:lang="en" lang="en">
<head>
  <title></title>
  <meta http-equiv="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)" />
  <meta name="created" content="Mon, 06 Sep 2010 07:35:27 GMT" />
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <meta name="description" content="" />
  <meta name="keywords" content="" />
  <meta http-equiv="Page-Enter" content="revealtrans(duration=2,transition=22)">
  
  <style type="text/css">
    a:link {text-decoration: none;}
    a:visited {text-decoration: none;}
  </style>
  
<style type="text/css">
BODY {
SCROLLBAR-FACE-COLOR: #0E98E0;
SCROLLBAR-HIGHLIGHT-COLOR: #000000;
SCROLLBAR-SHADOW-COLOR: #000000;
SCROLLBAR-3DLIGHT-COLOR: #000000;
SCROLLBAR-ARROW-COLOR: #000000;
SCROLLBAR-TRACK-COLOR: #000000;
SCROLLBAR-DARKSHADOW-COLOR: #000000;
background-image:url('Images/background.gif');
}
</style>
  
<style type="text/css">
div.Object1 { position:absolute; top:0%; left:0%; z-index:2; width:100%; height:20%;}
div.Object2 { position:absolute; top:20%; left:0%; z-index:2; width:100%; height:80%;}
</style>

</head>
<body>

<div class="Object1">
<table border="0"  width="100%" cellpadding="5" cellspacing="5"><tr><td>
<font size="7" face="AR CHRISTY"><b><u>YOUR SHOPPING CART</u></b></font>
</td></tr></table>
</div>

<div class="Object2">

<table border='1'  width='100%'> 
<tr><!-- Row 1 -->
   <td colspan="2" width='70%' align='left' valign='top'><font size="4" face="AR CHRISTY"><b>PRODUCT</b></font></td><!-- Col 2 -->
   <td width='15%' align='center' valign='top'><font size="4" face="AR CHRISTY"><b>QUANTITY</b></font></td><!-- Col 3 -->
   <td width='15%' align='center' valign='top'><font size="4" face="AR CHRISTY"><b>PRICE</b></font></td><!-- Col 4 -->
</tr>

<?PHP

$UserID = session_id();

include("database.php");

mysql_select_db("brandysbeanies", $con);

$result = mysql_query("SELECT * FROM productorders WHERE ClientID='$UserID'");

while($row = mysql_fetch_array($result))
{

echo"
  <tr><!-- Row 2 -->
     <td width='20%' align='center' valign='top'><a href='Products3.php?SKU=$row[0]' style='color:#000000;'><img src='$row[10]' width=60% height=60% alt='' border='1'></a></td><!-- Col 2 -->
     <td width='50%' align='left' valign='top'><font size='3' face='Comic Sans MS'><b>$row[3]</b><br>$row[4]</font></td><!-- Col 2 -->
     <td width='15%' align='center' valign='top'><font size='3' face='Comic Sans MS'>$row[7]</font></td><!-- Col 3 -->
     <td width='15%' align='center' valign='top'><font size='3' face='Comic Sans MS'>$row[9]</font></td><!-- Col 4 -->
  </tr>";
  
}
  
echo"
  <tr><!-- Row 2 -->
     <td width='85%' colspan=3 align='right' valign='top'><font size='4' face='AR CHRISTY'><b>SHIPPING</b></font></td><!-- Col 3 -->
     <td width='15%' valign='top'></td><!-- Col 4 -->
  </tr>";
  
echo"
  <tr><!-- Row 2 -->
     <td width='85%' colspan=3 align='right' valign='top'><font size='4' face='AR CHRISTY'><b>TOTAL</b></font></td><!-- Col 3 -->
     <td width='15%' valign='top'></td><!-- Col 4 -->
  </tr>";
?>

</table>
</div>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.