Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.