Jump to content

Need help cleaning script and finding errors


GOLDfish_74

Recommended Posts

I have made this page to change the values of the table "stock_levels" when products are received. I have yet to put any information in the tables in question just to make sure it will say any errors. But this script is returning no errors. Can someone help me clean up the script and find out why it reports no errors.

 

 

<html>

<head>

<link href="../style.css" rel="stylesheet" type="text/css" />

</head>

 

<?
if (isset($_POST['submit'])){
if(!isset($_POST['qty'])){
echo('You have not filled out the required field "Quantity."');
exit();
} if (isset($_POST['ean'])){
	$ean = ($_POST['ean']);
	$getdetail = mysql_query("SELECT item_id, item_fullname, item_description FROM item_details WHERE item_ean='$ean'") or die(print (mysql_error));
        $row = mysql_fetch_assoc($getdetail);
	$itemid = ($row['item_id']);
	$itemname = ($row['item_fullname']);
	$desc = ($row['item_description']);
} elseif (isset($_POST['model'])){
	$model = ($_POST['model']);
	$getdetail = mysql_query("SELECT item_id, item_fullname, item_description FROM item_details WHERE item_trunname='$model' OR item_fullname='$model'") or die(print (mysql_error));
        $row = mysql_fetch_assoc($getdetail);
	$itemid = ($row['item_id']);
	$itemname = ($row['item_fullname']);
	$desc = ($row['item_description']);
} else {
	echo('An error has occured, not all fields were entered correctly. Please press the back button on your browser to try again.');
	exit();
}
$qty = ($_POST['qty']);
if (is_numeric($qty)==false){
	echo("Quantity can only be entered as whole number amounts.");
	exit();
}
$setting = mysql_query("SELECT stock_soo, stock_soh FROM stock_levels WHERE stock_item_id='$itemid'");
$rows = mysql_fetch_assoc($setting);
$soo = ($rows['stock_soo'] - $qty);
$soh = ($rows['stock_soh'] + $qty);
$entry = mysql_query("UPDATE stock_levels SET stock_soh='$soh', stock_soo='$soo' WHERE stock_item_id='$itemid'") or die(print (mysql_error)); 
} else {
?>

 

<body>

<form method="post" action="srs.php?p=1]" class="bgeneral">

<table border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td colspan="2"><span class="title">Receive Order</span><br /> </td>

  </tr>

  <tr>

    <td align="right">EAN:</td>

    <td><input type="text" name="ean" accesskey="e" tabindex="0"></td>

  </tr>

  <tr>

    <td colspan="2" align="center"><br>     

    or;<br>

       </td>

  </tr>

  <tr>

    <td align="right">Model #:</td>

    <td><input type="text" name="model" accesskey="w" tabindex="1"></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td align="right">Amount Recieved:</td>

    <td><input type="text" name="qty" accesskey="q" tabindex="2"></td>

  </tr>

  <tr>

    <td> </td>

    <td> <br /><input type="submit" name="submit" value="submit" /></td>

  </tr>

</table>

</form>

 

<?
}
?>

 

</body>

</html>

 

 

Thanks anyone,

 

Regards,

 

THEfish!

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.