Hi, i am trying to execute the following code, and i get the error message above my form saying:
"Notice: Undefined variable: post in c:\program files\apache group\apache\htdocs\website\new.php on line 4
Notice: Undefined variable: post in c:\program files\apache group\apache\htdocs\website\new.php on line 39"
the code im using is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
$dbuser = "root";
$dbserver = "localhost";
$dbpass = "";
$dbname = "synergy";
if ($post == "yes") {
//THEN WE ARE POSTING UPDATES TO A RECORD
//** BEGIN UPDATE SQL**
//REPLACE THE FIELD CONTENTS SO THEY DON'T MESS UP YOUR QUERY
$Domestic_ID = addslashes($Domestic_ID);
$Domestic_ID = ereg_replace( "(\n)", "<BR>", $Domestic_ID );
$Industrial_ID = addslashes($Industrial_ID);
$Industrial_ID = ereg_replace( "(\n)", "<BR>", $Industrial_ID );
$Order_Date = addslashes($Order_Date);
$Order_Date = ereg_replace( "(\n)", "<BR>", $Order_Date );
$Product_Sku = addslashes($Product_Sku);
$Product_Sku = ereg_replace( "(\n)", "<BR>", $Product_Sku );
$Quantity = addslashes($Quantity);
$Quantity = ereg_replace( "(\n)", "<BR>", $Quantity );
$Total_Amount = addslashes($Total_Amount);
$Total_Amount = ereg_replace( "(\n)", "<BR>", $Total_Amount );
//CONNECTION STRING
mysql_connect($dbserver, $dbuser, $dbpass)
or die ("UNABLE TO CONNECT TO DATABASE");
mysql_select_db($dbname)
or die ("UNABLE TO SELECT DATABASE");
//SQL STRING
$sql = "UPDATE order SET
Domestic_ID='$Domestic_ID',
Industrial_ID='$Industrial_ID',
Order_Date='$Order_Date',
Product_Sku='$Product_Sku',
Quantity='$Quantity',
Total_Amount='$Total_Amount'
WHERE id='$id'";
$result = mysql_query($sql);
if ($result == 1) {
echo "Updated";
} else {
echo "Error Updating Record";
}
//** END UPDATE SQL **
} //END IF POST IS YES
if ($post == "") {
//THEN WE ARE EDITING A RECORD
//** BEGIN EDIT FORM**
//CONNECTION STRING
mysql_connect($dbserver, $dbuser, $dbpass)
or die ("UNABLE TO CONNECT TO DATABASE");
mysql_select_db($dbname)
or die ("UNABLE TO SELECT DATABASE");
$sql = "SELECT * FROM order WHERE id = $id";
$result = mysql_query($sql);
if ($myrow = mysql_fetch_array($result)) {
do
{
?>
<form method="post" action="<?php echo $SCRIPT_NAME; ?>?post=yes">
<TABLE>
<tr>
<td>
<B>DOMESTIC_ID: </B>
</td>
<td>
<? $Domestic_ID = $myrow["Domestic_ID"]; ?>
<input type="text" name="Domestic_ID" value="<?php echo $Domestic_ID; ?>" size="20">
<tr>
<td>
<B>INDUSTRIAL_ID: </B>
</td>
<td>
<? $Industrial_ID = $myrow["Industrial_ID"]; ?>
<input type="text" name="Industrial_ID" value="<?php echo $Industrial_ID; ?>" size="20">
<tr>
<td>
<B>ORDER_DATE: </B>
</td>
<td>
<? $Order_Date = $myrow["Order_Date"]; ?>
<input type="text" name="Order_Date" value="<?php echo $Order_Date; ?>" size="20">
<tr>
<td>
<B>PRODUCT_SKU: </B>
</td>
<td>
<? $Product_Sku = $myrow["Product_Sku"]; ?>
<input type="text" name="Product_Sku" value="<?php echo $Product_Sku; ?>" size="20">
<tr>
<td>
<B>QUANTITY: </B>
</td>
<td>
<? $Quantity = $myrow["Quantity"]; ?>
<input type="text" name="Quantity" value="<?php echo $Quantity; ?>" size="20">
<tr>
<td>
<B>TOTAL_AMOUNT: </B>
</td>
<td>
<? $Total_Amount = $myrow["Total_Amount"]; ?>
<input type="text" name="Total_Amount" value="<?php echo $Total_Amount; ?>" size="20">
<tr>
<td>
</td>
<td>
<?
$id = $myrow["id"];
?>
<input type="hidden" value="<?php echo $id; ?>" name="id">
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset">
</td>
</tr>
</table>
<BR>
</form>
<?
}
while ($myrow = mysql_fetch_array($result));
}
} //END IF POST IS "" (THIS IS THE END OF EDITING A RECORD)
//** END EDIT FORM**
?>
can anyone tell me how i define the post thing?
what is it im supposed to type there?
many thanks