
Untitled
By: a guest on
Jul 15th, 2012 | syntax:
None | size: 1.80 KB | hits: 12 | expires: Never
Passing the ID from one page to another [closed]
echo "<td> <a href='products.php?IsEdit=1&ProductID=" .$row['ProductID']. "'> Edit </a></td>";
<?php
global $ID;
$ID = $_GET['ProductID'];
<?php
if(isset($_GET['IsEdit']))
{ ?>
<input type="submit" name = "update" value="UPDATE" onClick="return valid();" />
<?php }else { ?>
<input type="submit" name = "submit" value="ADD PRODUCT" onClick="return valid();" />
<?php } ?>
if (isset($_POST['update']))
{
$ProductName = mysql_real_escape_string(htmlspecialchars($_POST['ProductName']));
$ProductCode = $_POST['ProductCode'];
$Manufacturer = $_POST['Manufacturer'];
$Specification = $_POST['Specification'];
$Description = $_POST['Description'];
$CostPrice = $_POST['CostPrice'];
$DisplayPrice = $_POST['DisplayPrice'];
echo "Pr ID";
echo $ID;
$ProductImage = $_POST['ProductImage'];
//{
echo "2";
if ($ProductName == '' || $ProductCode == ''|| $Manufacturer == '' || $Description == '' || $Specification == '' || $CostPrice == '' || $DisplayPrice == '')
{
// generate error message
$error = 'ERROR: Please fill in all required fields!';
echo "3";
//error, display form
//renderForm('', $ProductID, $ProductName, $ProductCode, $Manufacturer, $Description, $Specification,'', $CostPrice, $DisplayPrice, $error);
}
else
{
// save the data to the database
$sql = "UPDATE Products SET ProductName='$ProductName', ProductCode='$ProductCode', Manufacturer='$Manufacturer', Description='$Description', Specification='$Specification', CostPrice='$CostPrice', DisplayPrice='$DisplayPrice' WHERE ProductID=" . $_SESSION['ID'];
echo $sql;
mysql_query($sql) or die(mysql_error());
// once saved, redirect back to the view page
//header("Location: view.php");
}
//}
}
$row['ProductID'] have valid data