Jump to content

Getting form information from $_POST


SCook

Recommended Posts

Hi gang,

Quick question: Is there a way to determine the type of the form variable that is sent to PHP? Just as you can do:

foreach($_POST as $key => $value) to get the name and value, there must be a way to get other form info too. Or is there someplace with a better description of $_post. PHP manual is very vague here. Thanks
Link to comment
Share on other sites

I want to know because I'm doing some dynamic form creation via the database table into which the form data must be entered. Then, when the form is submitted, I'm building the query out of the names and values of the form elements, as their names match the mysql field names. The form is retty large, and if this works out, it'll save me hours of programming. I'm trying to oop the form to database process.

I could use JavaScript to create a list of types, or as you say, I could do something like this: <input type = "text" name = "t-address" > wherein I could split each $key by the dash, or whatever, and with switch case the character before it to get the type. I was just hoping there might be a built in way.

Oh, I forogot one thing. You may still be asking why I want the types, the reason is that I need to filter out the non-data elements like hidden, submit, button, reset, etc. And if the form elements contains information that needs to be entered as strings or int or decimal, I ned to know that to propertly format the query.
Link to comment
Share on other sites

.. moving this along (I hope) ..

If the 'non-data' inputs had their names identifiable, e.g. all named ignore_[input name], you could skip over them in the loop where you retrieve the $_POST array keys/values. That would remove one problem. Hidden inputs need to be handled differently as they presumably exist for some post-submission processing purpose.
Link to comment
Share on other sites

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.