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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.