Hi everyone,
I have a catalogue table in MySQL which has the following fields (yacht sales website):
Boat_ID
Boatname
Price_dollars
The table has 5 yachts in it with Boat_ID from 1 to 5.
I have made a catalogue page in HTML, and added a 'Buy Now' button next to each of the yacht's details. What code would I need to link this 'Buy Now' button to an orderform that includes the boat details at the top, with fields for the person to enter their details underneath. The code I have so far is as follows (orderform.php)
<?
if(!$submit) // if no submit button has been pressed
{
?>
<form action="orderform.php" method="post">
<br>
<br>
<h3>Your Details:</h3>
<br>
<br>
First name:
<input name="firstname" type="Text" size="30">
<br>
<br>
Last name:
<input name="lastname" type="Text" id="lastname" size="30">
<br>
<br>
House Name / No:
<input name="house" type="Text" size="30">
<br>
<br>Address Line 1:
<input name="address1" type="Text" size="50">
<br>
<br>
Address Line 2:
<input name="address2" type="Text" size="50">
<br>
<br>
Town / City:
<input name="town" type="Text" size="50">
<br>
<br>
Postcode:
<input name="postcode" type="Text" size="10">
<br>
<br>
<br>
If you would like the Yacht to be delivered to an address other than the above, please complete the delivery address details below:
<br>
<br>
<h3>Delivery Address:</h3>
<br>
House Name / No:
<input name="delivery_house" type="Text" size="30">
<br>
<br>Address Line 1:
<input name="delivery_address1" type="Text" size="50">
<br>
<br>
Address Line 2:
<input name="delivery_address2" type="Text" size="50">
<br>
<br>
Town / City:
<input name="delivery_town" type="Text" size="50">
<br>
<br>
Postcode:
<input name="delivery_postcode" type="Text" size="10">
<br>
<br>
<br>
<input type="Submit" name="submit" value="Enter information">
<input type="Reset" name="reset" value="Clear This Form">
</form>
<?
} else { // if the submit button has been pressed
<?
$username="xxxxxx";
$password="xxxxxx";
$database="db_xxxxxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$house = $_POST['house'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$town = $_POST['town'];
$postcode = $_POST['postcode'];
$delivery_house = $_POST['delivery_house'];
$delivery_address1 = $_POST['delivery_address1'];
$delivery_address2 = $_POST['delivery_address2'];
$delivery_town = $_POST['delivery_town'];
$delivery_postcode = $_POST['delivery_postcode'];
$query = "INSERT INTO orderform VALUES
('', '$firstname','$lastname', '$house', '$address1','$address2', '$town', '$postcode',
'$delivery_house', '$delivery_address1', '$delivery_address2', '$delivery_town', '$delivery_postcode')";
mysql_query($query);
mysql_close();
header("Location:thanks.html");
}
?>
What needs to be added to the beginning of this code to drag the relevant yacht's details through to this form?
Any help much appreciated.