I have set up a database driven Web site selling used boats, boat parts, engines, etc…
I am in the process of designing entry forms for the owner to update boats, boat parts, etc for sale. I made a form that works for boats. The form for boat parts is not working.
Here is the html form from the EnterBoatPart.php:
<form action=“ProcessBoatPart.php” method=“post” name=“addBoatPart” onreset=“return confirm(‘Do you want to clear this form?’)”>
<table cellpadding=“3” bgcolor=“#FFFFFF” >
<tr>
<td><label>Part</label></td>
<td><textarea name==“part” id=“part” cols=“40” rows=“2”></textarea></td>
<td><label>Price</label></td>
<td><input type=“text” name=“price” id=“price” size=“15” /></td>
</tr>
<tr>
<td><label>Part Description</label></td>
<td><textarea name=“description” cols=“40” rows=“5”></textarea></td>
<td><label>Picture</label></td>
<td><textarea name=“picture” cols=“40” rows=“3”></textarea></td>
</tr>
<tr>
<td><label>Item</label></td>
<td><input type=“text” name=“item” id=“item” size=“11” /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right"><input name="save" type="submit" value="Save" /></td>
<td colspan="2" align="center"><input name="add_another" type="button" value="Save and Add Another Boat" /></td>
<td align="left"><input name="reset" type="reset" value="Reset" /></td>
</tr>
</table>
</form>
Here is ProcessBoatPart.php:
<?php
$part = $_POST[‘part’];
$price = $_POST[‘price’];
$item= $_POST[‘item’];
$description = $_POST[‘description’];
$picture= $_POST[‘picture’];
$dbhost = ‘localhost’;
$dbuser = ‘root’;
$dbpass = ‘password’;
$database = ‘used_boats’;
$table = ‘Boat_Parts’;
if (!mysql_connect($dbhost, $dbuser, $dbpass))
die(“Can’t connect to database”);
if (!mysql_select_db($database))
die(“Can’t select database”);
$sql = “INSERT INTO Boat_Parts (CategoryID, PartID, Part, PartDescription, Picture, Price, Item) values (‘4’, ‘’, ‘$part’, ‘$desciption’, ‘$picture’, ‘$price’, ‘$item’ )”;
echo(mysql_error());
mysql_query($sql) or die(mysql_error());
echo “A <strong>$part<br />
$description<br />
$picture<br />
$price<br />
$item has been added to the database.</strong>”;?>
This is my error message:
! ) Notice: Undefined index: part in C:\\wamp\\www\\ProcessBoatPart.php on line 16
Call Stack
# Time Memory Function Location
1 0.0011 378416 {main}( ) ..\\ProcessBoatPart.php:0
( ! ) Notice: Undefined variable: desciption in C:\\wamp\\www\\ProcessBoatPart.php on line 37
Call Stack
# Time Memory Function Location
1 0.0011 378416 {main}( ) ..\\ProcessBoatPart.php:0
A
1980s Antique mahogany Chris-Craft galley table. Not many left in the world. Leafs on both sides fold-down. Table has not been restored. Warehouse stored over 20 years. Iron floor mounts. Mahogany solid.
$1000 OBO
625 has been added to the database.