Jump to content

[SOLVED] Validation for a dynamic form


coffejor

Recommended Posts

Hello all,

 

I have an order form that is built dynamically from my products database and would like to create a dynamic validation and form processor.

 

I have created a good validation scheme by hardcoding the names of the fields from the orderform, an example is as follows

 

$two_a = $_POST['PROD_cub_bear_patch_3x3_4'];

$two_b = $_POST['PROD_cub_bear_patch_special_10'];

$two_c = $_POST['PROD_cub_club_patch_3'];

 

The names like PROD_cub_bear_patch_3x3_4 are stored in fields in a database corresponding to their appropriate product and can be easily retrieved. I would like to make a while loop that goes through the database and creates the variable dynamically from the post based on whats in the database.

 

A possible solution is as follows

 

$result = @mysql_query('SELECT * FROM products WHERE category AND status="1"');

while ($row = mysql_fetch_array($result)) {

$name = $row['name'];

echo '$'.$name.' = $row[/''.$name.'/'];';

}

 

*NOTE: $name is the name of the product field that is stored in the database

 

I'm not sure how to make this work and would be really appreciative of any input/insight that any of you may have.

 

Thanks in advance.

 

Jordan

Link to comment
https://forums.phpfreaks.com/topic/49271-solved-validation-for-a-dynamic-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.