Jump to content

Fetching The Name Of A Form Field From $_post


chibineku
 Share

Recommended Posts

I would like to be able to detect the name of the form field that a script has been sent via the $_POST variable array. Only one value will be set at a time. So, I need to know $_POST["this_bit"], but I don't know how to reference that.edit: I will explain my idea, so I know if it'll work before I proceed:I want to create a form that displays a user's current personal data and lets them save it. I could have the form handler be one big script that can cope with any and all changes, but I thought it'd be easier to have a little button next to each field and if one is changed, only one form field is posted to the handler at a time, which could then return true or false to the form page. Would that work or do I need AJAX for that? It'd be fun to dust off my AJAX anyway...

Edited by chibineku
Link to comment
Share on other sites

You can loop through everything in $_POST using foreach:

foreach ($_POST as $k => $v){  echo 'key: ' . $k . '; value: ' . $v . '<br>';}

You can also use array_keys to get an array of the keys in another array.

Edited by justsomeguy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...