Trouble with multiple PHP/SQL queries?

I'm attempting to build a website with various PHP/SQL functions for a fictional motorhome dealership as part of an assignment. One of the required functions is to update entries in the SQL database, which is currently giving me a single, large problem.
The update process is made up of 3 pages, the first has a dynamically filled dropdown menu that populates with all the ID numbers of all the database entires. When one is chosen and the 'submit' button is pressed, the next page comes up. Here, with the exception of the ID number, all the information in the appropriate row is displayed in it's own text field. This works no problem, however, when the submit button on this page is hit, I'm given the error code 'Undefined index: motorID' and I can't figure out why.
This is my current PHP coding:
Page 1:
<form name = "UpdateMotorhome" id = "UpdateMotorhome"
action = "adminUpdateQuery1.php" method = "post">

<?php
include 'database_conn.php';
$sql = "SELECT motorID FROM motorhomes";
$result = mysql_query($sql)
or die(mysql_error());

$options = "";

while ($row = mysql_fetch_array($result)) {

$motorID = $row['motorID'];
$options.= "<OPTION VALUE=\"$motorID\">".$motorID.'</option>';
}
?>

<SELECT NAME=motorID>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT>
<input type = "submit" value = "submit" />
</form>

Page 2:
<?php

$mID = $_REQUEST['motorID'];

include 'database_conn.php';
$sql = "SELECT * FROM motorhomes WHERE motorID = '$mID'";
$queryresult = mysql_query($sql)
or die(mysql_error());

while ($row = mysql_fetch_assoc($queryresult)){
$motorID = $row['motorID'];
$manufacturer = $row['manufacturer'];
$model = $row['model'];
$year = $row['year'];
$engine = $row['engine'];
$berths = $row['berths'];
$mileage = $row['mileage'];
$price = $row['price'];
$layout = $row['layout'];
$ownership = $row['ownership'];
$description = $row ['description'];
?>

<form name = "UpdateMotorhomePart2" id = "UpdateMotorhomePart2"
action = "adminUpdateQuery2.php" method = "post">

<?php
echo "<div id=\"result\">";
echo "Motorhome ID: $motorID<br />";
echo "Manufacturer: <input type = \"text\" name = \"manufacturer\" value=\"$manufacturer\"><br />";
echo "Model: <input type = \"text\" name = \"model\" value=\"$model\"><br />";
echo "Year: <input type = \"text\" name = \"year\" value=\"$year\"><br />";
echo "Engine: <input type = \"text\" name = \"engine\" value=\"$engine\"><br />";
echo "Berths: <input type = \"text\" name = \"berths\" value=\"$berths\"><br />";
echo "Mileage: <input type = \"text\" name = \"mileage\" value=\"$mileage\"><br />";
echo "Price: <input type = \"text\" name = \"price\" value=\"$price\"><br />";
echo "Layout: <input type = \"text\" name = \"layout\" value=\"$layout\"><br />";
echo "Ownership: <input type = \"text\" name = \"ownership\" value=\"$ownership\"><br />";
echo "Description: <input type = \"text\" name = \"description\" value=\"$description\"><br />";
echo "<hr />";
echo "</div>";
}
?>

<input type = "submit" value = "submit" />

</form>

Page 3:
<?php
include 'database_conn.php';

$motorID = $_REQUEST['motorID']; //Line error keeps occuring on
$manufacturer = $_REQUEST['manufacturer'];
$model = $_REQUEST['model'];
$year = $_REQUEST['year'];
$engine = $_REQUEST['engine'];
$berths = $_REQUEST['berths'];
$mileage = $_REQUEST['mileage'];
$price = $_REQUEST['price'];
$layout = $_REQUEST['layout'];
$ownership = $_REQUEST['ownership'];
$description = $_REQUEST['description'];

$sql = "UPDATE motorhomes SET manufacturer = '$manufacturer', model = '$model', year = '$year',
engine = '$engine', berths = '$berths', mileage = '$mileage', price = '$price', layout = '$layout',
ownership = '$ownership', description = '$description' WHERE motorID = '$motorID'";
$queryresult = mysql_query($sql)
or die(mysql_error());

echo "Record Updated";


?>

Thanks for any advise in advance.

p.s.
I tried a similar set up with the Remove from database function (without editable data on 2nd page) that gave me the same problem. I eventually removed the 2nd page and the function started working correctly.
 
Back
Top