Jump to content


Photo

Using arrays with forms


  • Please log in to reply
No replies to this topic

#1 fezzik

fezzik
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 02 October 2006 - 09:56 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users