Jump to content

Get names & values of all HTML form elements with PHP


cbassett03

Recommended Posts

How can I get the names and values from an HTML form using PHP when the form is submitted using a Submit button?

I think this may involve using a foreach loop (since the form will be dynamically created each time depending on other factors).

But I need to be able to capture the form control's name and its value when it is submitted.

i would recommend against unconditionally looping over all submitted form data (a hacker/bot can submit hundreds/thousands of pieces of data.) you should know what fields your form will submit and if you are dynamically adding fields, their names should be of a known scheme (array names) so that you know what to expect when you condition, filter, validate, and process the submitted data.

Archived

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

×
×
  • Create New...

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.