Skip to content
Advertisement

How do I pass these variables to another php file

I’m currently making a shopping website and I need to be able to pass two variables to the next page, the code may be badly written because I’m new to this, but I’m trying to pass the number from the drop-down menu and the “row[‘pid’]” to another page. As shown below I have attempted to use a form button but it can only transfer the number from the dropdown. There is database connected so if you try to load it up, it may not load anything. This issue is specifically focussing on the button which the form is linked to at the end. Thank you for your time.

JavaScript

Advertisement

Answer

If you want to transfer the PID when the form is submitted then you need a field for it within the form, e.g. a hidden field like this:

JavaScript

Then when you submit the form, it will be accessible as $_POST["pid"] (just like the value from the dropdown is accessible as $_POST["quantity"]).

This applies to any value – if you want it to be submitted with the form, then there needs to be a proper field for it within the form (or least associated with the form via the necessary attribute).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement