Jump to content

Archived

This topic is now archived and is closed to further replies.

stualk

PHP Order Form

Recommended Posts

Hi Chaps,

I have a site which calls in products from a database and displays them on a page. What I've now done is to create a hyperlink from the product code of each product to an order form, so effectively you can add an item to the order form. So far so good with this. The hyperlink takes the values '$item_number' and '$product_name' into the PHP order form.

Up to now this works perfectly but people can only add one item to the order form. How can I make sure that my order form adds a new row and the relevant boxes each time someone updates their order by clicking on another item?

Here's the code of the order form (I only have one row currently in the table that displays the products):

[code]
<?php

print("
<form name=\"form1\" method=\"post\">
<input type=\"hidden\" name=\"action\" value=\"addscript\" size=\"20\">
<table width='580' border='1' cellpadding='2' cellspacing='0' bordercolor='#000000'>
  <tr valign='top'>
    <td width='70%'><div align='center'><font size='2'><strong>Product Description</strong></font></div>
    </td>
    <td width='15%'><div align='center'><font size='2'><strong>Product Code</strong></font></div></td>
    <td width='15%'><div align='center'><font size='2'><strong>Quantity</strong></font></div></td>
  </tr>
  <tr>
    <td width='70%'><input name='desc11' type='text' id='desc11' value='$product_name' size='45'></td>
    <td width='15%'><div align='center'>
      <input name='code11' type='text' id='code11' value='$item_number' size='20'>
    </div></td>
    <td width='15%'><div align='center'>
      <input name='qty11' type='text' id='qty11' size='5'>
    </div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align='center'>
      <input type='submit' name='Submit' value='Submit Order'>
    </div></td>
    <td><div align='center'>
      <input type='reset' name='Submit2' value='Reset'>
    </div></td>
  </tr>
</table>
</form>
");

?>[/code]

Any know how best I can achieve this?

Thanks

Share this post


Link to post
Share on other sites
When you say 'adding to the order form', are you storing this information somewhere, like in the database?

Regards
Huggie

Share this post


Link to post
Share on other sites
What you want is a shopping cart.

You need to keep track of a number of selections and assocciate them with a session_id/ip_address/username (if applicable).
Then when they "check-out" the shopping cart you can create a dynamic form with all the items from their shopping cart.

Have a look at these links for some ideas:
[url=http://php.resourceindex.com/Complete_Scripts/Shopping_Carts/]http://php.resourceindex.com/Complete_Scripts/Shopping_Carts/[/url]
[url=http://www.shop-script.com/]http://www.shop-script.com/[/url]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.