Jump to content

Using arrays with forms


fezzik

Recommended Posts

Some of you might be familiar with web sites that sell cell phones and SIM cards. Usually on these sites there is an option to "reload" your SIM card. I'm trying to create a form that has the same functionality as most reload forms. Basically the form has an option to update quanity and another field that allows you to input your telephone number so they can reload the SIM card. So the form should look similar to:

<table>
  <form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST">
  <tr>
    <td colspan="3">Reload Telephone#: <input name="reloadNumber" id="reloadNumber" type="text">
  </tr>
<input type="hidden" name="product_Reload" value="Reload"> <input type="hidden" name="cost_Reload" value="80.00">
  <tr>
    <td>Quanity:</td>
    <td><input name="qty_Reload" type="text" value="1"></td>
    <td><input name="submit" type="submit" value="Add to Basket"></td>
  </tr>
  </form>
</table>

Once the form is submitted the data from the form is stored in session variables. Currently I'm able to correctly store this data in the session variables I assign except for the "reload telephone number". The session variable that stores the "reload telephone number" changes value with every form submission. So, the previous stored number is replaced by the new one. I think I need to create an array to hold multiple "reload telephone numbers" associated with this "reload product." How can I use an array and the form above to accomplish this? I'm looking at this from the perspective that a user might want to purchase multiple reloads for multiple numbers. I might be incorrect in my assumption of using an array to acheive this functionality so any advice to alternative methods is much appreciated. If you need additional information please ask.

Cheers,

Fezzik
Link to comment
https://forums.phpfreaks.com/topic/22800-using-arrays-with-forms/
Share on other sites

Archived

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

×
×
  • Create New...

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.