Jump to content


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


Using arrays with forms

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:

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

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.



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.