SCook Posted March 11, 2006 Share Posted March 11, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/4684-getting-form-information-from-_post/ Share on other sites More sharing options...
AndyB Posted March 11, 2006 Share Posted March 11, 2006 Quick answer: No.Quick question: Why do you care/need to know?Quick-and-dirty option: use logical form variable names to distinuguish input types. Quote Link to comment https://forums.phpfreaks.com/topic/4684-getting-form-information-from-_post/#findComment-16398 Share on other sites More sharing options...
SCook Posted March 11, 2006 Author Share Posted March 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4684-getting-form-information-from-_post/#findComment-16401 Share on other sites More sharing options...
AndyB Posted March 11, 2006 Share Posted March 11, 2006 .. 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. Quote Link to comment https://forums.phpfreaks.com/topic/4684-getting-form-information-from-_post/#findComment-16403 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.