I'm new at PHP stuff HELP PLEASE!

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.

<head><title>Car Catalog</title></head>
<body topmargin="0" marginheight="0">

  /*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>&nbsp;</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'>";
  while ($row = pg_fecth_array($result))
     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>
     echo "</tr>";
  echo "<t/table>";
  echo "<p><input type='submit' value'Check out'></form>n"; 



Checkout <?php


* required

* First name:
* Last name:
* Email:
Phone number:
* City:
* State:
* Zip code:
* Country:

?> [/code]

Where exactly are you getting stuck? Do you have a table for your orders? I presume using INSERT and UPDATE statements shouldn’t be too much of a problem for you since you’ve already gotten so far, and fetching POST variables doesn’t look like they could be the problem either. And that’s basically all you need.

I do have a order table, it contains all the user’s info(Name, adress…but it doesn’t not contain price), maybe I should add price? Where I m stuck is going between pages(catalog to checkout). It is only storing the customer information, and not the order information.

Then you should alter your table so it becomes possible to store your order information.

Sponsor our Newsletter | Privacy Policy | Terms of Service