itachi77 Posted June 7, 2010 Share Posted June 7, 2010 Hi all, just signed up and this forum looks like a pretty good source of information. I am a beginner to PHP and would like help in relation to reloading of a php page. I have two text boxes in which a user can specify the name of a product and the quantity they would like. They have the option to add more products so when they click on the Add Product button the page reloads and the selection they made is added to an associative array which can on submission of the complete form be used in an sql query to retrieve price etc. The problem is every time the page reloads the array needs to be redefined so the previous product information is lost. Is there a way to reload the page but not having to redefine the array? Only one person is going to be using this application hence not using cookies. Thanks <?php $products=array(); if(isset($_POST['product'])){ $products +=array($_POST['product']=>$_POST['quantity']); } else { } foreach($products as $ind=>$val) echo "$val : $ind" ."<br>" ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method='POST'> <input type="text" name="product"/> <input type="text" name="quantity"/> <input type="submit" value="Add Product"/> </form> Quote Link to comment Share on other sites More sharing options...
TOA Posted June 7, 2010 Share Posted June 7, 2010 Only one person is going to be using this application hence not using cookies. Thanks Doesn't matter. Cookies or actually sessions is probably your best bet. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.