I am new/bad at php don't kill me please. 🙂
I am developing a script that stores user info: firstName, lastName, address1 etc... I am trying to use a relational database so each variable (firstName, lastName etc...)has its own table with a matching user_id as key.
I thought if I used a table that held all of these variables I could dynamically create my forms so that I can modify the variables without modifying code down the road. Also, I thought it would make life easier when making other forms too.
Table:

I have gotten past the part of creating the forms. Now I am trying to retrieve the form data via $POST so I can INSERT it into the appropriate database. But I need to create these $POST statements dynamically like this:
$firstName=trim($_POST[firstName]);
I can generate this code, but how do I get PHP to evaluate this as php code and not just output text? I tried using eval() but I think it is a poor solution and I can't seem to get it to work.
$queryVarForm="SELECT field FROM `customerInfo`";
$resultsVarForm=mysql_query($queryVarForm);
while ($row=mysql_fetch_assoc($resultsVarForm)) {
$field=$row[field];
//echo $field;
//echo "<br />";
$tempa = "$".$field."=trim(\$_POST['".$field."']);";
//echo $tempa;
$temp=eval("$tempa");
//echo $temp;
After this step I would have to set up a bunch of INSERT statements.
It seems to me like this is probably a VERY common script. Let me know if I should be taking a completely different approach.
Thanks