PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have been working on a catalog application. I am having trouble with transferring the information of a product (which are displayed from the database, each in it's own form). When I check to see if the form (from the product) has been submitted so I can transfer the variables to a cookie to send to the shopping cart the product name variable is not set.
I want to get the product name variable from the form to the bottom of the code in the if isset submitted section.
Any help would be greatly appreciated.
Here is the code from the section I am having problems with. It may be important to note that I have a form that creates product categories earlier in the code that also uses the POST array however I am still having issues even using the GET array.
if(isset ($_POST['submitted']) and $_POST['submitted'] =="yes"){
echo "It has been submitted";
echo $_POST['product_name'];
When I submit a product "it has been submitted" is printed. However, the product name is either ignored (and not printed) or I'm told that there is no value set for the 'product_name'.
You cannot ask for $_POST['product_name'] on the same page where you are having your form, at least not using the different .php file as form action (of course there are ways to do that but that's not the point). When you set ProdutCatalog.php as action of your form, that means that all values from that form are going to be accessible to file ProductCatalog.php in $_POST variable, NOT the same file where your form is. Go, try it out, ask for the $_POST['product_name'] in ProductCatalog.php page and you will get it. The reason why
is working and not the next line should be obvious to you by now. If, perhaps, you check whether $_POST['product_name'] has been set instead of $_POST['submitted'],