I am trying to create a form that allows me to modify information in a database - i was sure this code would work however it does not allow me to modify the info at all. There is 2 files being used to do this operation. They are both shown below:
Can anyone please help!!
<?php
$db = mysql_connect("localhost", "9900000");
mysql_select_db("9900000",$db);
if (@$modifyDatabase=="yes") {
$dbQuery="UPDATE products SET producttype='$theproducttype', productprice='$theproductprice', productquantity='$theproductquantity' WHERE productname='$theproductname' " .
$result = mysql_query($dbQuery,$db);
header("Location: products.html");
}
else {
?>
<html>
<head>
<title>Product Database - Modify a Product</title>
<link rel=stylesheet href=projectstyles.css>
</head>
<body>
<?php
$dbQuery="SELECT * FROM products WHERE producttype='$theproducttype' and productname='$theproductname' ";
$result = mysql_query($dbQuery,$db);
$productInfo=mysql_fetch_array($result);
$producttype=$productInfo["producttype"];
$productname=$productInfo["productname"];
$productprice=$productInfo["productprice"];
$productquantity=$productInfo["productquantity"];
?>
<p> </p>
<table class=border align=center width=800 cellspacing=0 cellpadding=5>
<tr><th>Modify Product Details</th></tr>
<tr><td>
<form action=modifyproductFields.php>
<input type=hidden name='modifyDatabase' value='yes'>
<table width=100% cellpadding=3 cellspacing=5 border=0>
<tr><td align=center>
<input type=hidden name=theproductname value='<?php echo "$productname " ?>'>
<font face=verdana size=2 color=darkred>
<strong><?php echo("$productname ") ?></strong></font><br>
</td></tr>
<tr><td align=center>
<font face=verdana size=2 color=navy>
Modify Product Type</font><br>
<input name=theproducttype type=text size=30 value="<?php echo("$producttype") ?>">
</td></tr>
<tr><td align=center>
<font face=verdana size=2 color=navy>
Modify Product Price</font><br>
<input name=theproductprice type=text size=30 value="<?php echo("$productprice") ?>">
</td></tr>
<tr><td align=center>
<font face=verdana size=2 color=navy>
Modify Product Quantity</font><br>
<input name=theproductquantity type=text size=30 value="<?php echo("$productquantity") ?>">
</td></tr>
<tr><td align=center>
<input type=submit value='Modify Product'>
</td></tr>
</table>
</form>
</td></tr>
</table>
</body>
</html>
<?php
}
?>
Second file:
<html>
<head>
<title>Product Database - Modify a Product</title>
<link rel=stylesheet href=projectstyles.css>
</head>
<body>
<?php
$db = mysql_connect("localhost", "9900000");
mysql_select_db("9900000",$db);
$dbQuery="SELECT * FROM products";
$result = mysql_query($dbQuery,$db);
?>
<p> </p>
<table class=border align=center width=700 cellspacing=0 cellpadding=5>
<tr><th>Choose an Entry to Modify</th></tr>
<tr><td>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<?php
while ($productInfo=mysql_fetch_array($result)) {
$producttype=$productInfo["producttype"];
$productname=$productInfo["productname"];
$productprice=$productInfo["productprice"];
$productquantity=$productInfo["productquantity"];
$numOfOrders=$productInfo["numOfOrders"];
echo "<tr valign=center> \n" .
" <td align=left> \n" .
" <form action=modifyproductFields.php> \n" .
" <input type=submit value='Modify'> \n" .
" <input type=hidden name=theproducttype value='$producttype'> \n" .
" <input type=hidden name=theproductname value='$productname'> \n" .
" <input type=hidden name=theproductprice value='$productprice'> \n".
" <input type=hidden name=theproductquantity value='$productquantity'> \n".
" $producttype - $productname - $productprice - $productquantity \n" .
" </form> </td> </tr> \n";
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>