I am trying to write a web based online catalog using php and postgresql. I’ve gotten to the point where the user finds something he wants to buy and is proceding to checkout. I’m stuck, where the user clicks on the submit order button, it’s supposed to take them a checkout page where they fill out there information. How do make it so that the information the user fills gets put in the database along with the product information he purchased. Help, please!
here is the code, the first page is the product selection page, the second one is supposed to be the user information page.
<html>
<head><title>Car Catalog</title></head>
<body topmargin="0" marginheight="0">
<?php
/*connection*/
/*Selects cars of the given type*/
$query = "SELECT * FROM Car WHERE carType="{$_POST['interest']}"";
$result = pg_query($query) or die ("Couldn't execute query.");
/*Displays the results in a table*/
echo "<table cellspacing='10' border='0' cellpading='0' width='100%'>";
echo "<tr><td colspan='5' align='right'></td></tr>n";
/*The loop runs once for each car that is selected and creates a line of info*/
while ($row = pg_fetch_array($result,PG_ASSOC))
{
$f_price = number_format($row['price'],2);
/*checks to see if the car comes in colors*/
$query = "SELECT * FROM Color WHERE carName='{$row['petname']}'";
/*shows the picture of the car if it has two colors*/
$result2= pg_query($query) or die(pg_error());
$ncolors = pg_num_rows($result2);
/*Displays a row for each car*/
echo "<tr>/n";
echo "<td>{$row['carId']}</td>n";
echo "<td><font size='+1'><b>{$row['carName']}</b></font></td>n";
echo "<td>{$row['carDescription']}</td>n";
/*Displays the picture if the car does not come with color
if ($ncolors <= 1)
{
echo "<td><a href='../images/{$row['pix']}'border='0'><img src='../images/{$row['pix']' border='0' width='100' height='80'></a></td>n";
}
echo "<td align='center'>$$f_price</td>n</tr>n";
/*Displays row for each color if car comes in colors*/
if ($ncolors > 1)
{
while($row = pg_fetch_array($result2.PG_ASSOC))
{
echo "<tr><td colspan=2> </td>
<td>{$row2['carColor']}</td>
<td><a href='../images/{$row2['pix']}'border='0'>
<img src='../images/{$row2['pix']}' border='0' width='100' height='80'></a></td>n";
}
}
echo "<tr><td colspan ='5'><hr></td></tr>n";
}
echo "</table>n";
echo "<div align='center'>
<a href='CarCatalog.php'>
<b>See more cars</b></a></div>";
/*Creates a form containing selection list*/
echo "<form action='CheckOut.php' method='post'>n";
echo "<table cellpadding='5' border='1'>";
$counter=1;
while ($row = pg_fecth_array($result))
{
extract($row);
echo "<tr><td valign='top' width='15%'>n";
echo "<input type='radio' name ='interest' value='$carType'n";
if ($counter == 1)
{
echo "checked";
}
echo "><font size='+1'><b>$carType</b></font>";
echo "</td>
<td>$typeDescription</td>";
echo "</tr>";
counter++;
}
echo "<t/table>";
echo "<p><input type='submit' value'Check out'></form>n";
?>
</body></html>
[code]
Checkout <?php/Connection/
|
|
* required |
|
* First name: | |
* Last name: | |
* Email: | |
Phone number: | |
Address: | |
* City: | |
* State: | |
* Zip code: | |
* Country: |
?> [/code]