PHP - detection of field names

Im programming a Content Management System and there is a lot of different forms and fields that users have to fill out and the information submitted is entered into a MySQL database.

Is there a way to create a function that will scan the file, find out the field names, validate the form (like make sure phone numbers are digits and make sure email address was properly entered) and create a database query according to the field names?

That way, I would only have ONE function to input the information in MOST of my forms and save a lot of repetitive work.

I know lots of us will find a function like this useful. Im going to do a search for something like this and I will post what I find. If I dont find anything and there is no one that as a function like this, I will try to create a function like this. But if you already have it please share it.

Thanks,

Leo