Page 1 of 1

dynamic form checking PROBLEM

Posted: Thu Jan 19, 2006 8:17 am
by brainpulse
Well i'm new to php and i want to do the following:


I have a form woth 32 fields and i want to check if this fields has values entered.

So, i think to use a for loop and to constract the checking value dynamically.

the posted fields has the same name except two characters - the numbers that defines the field indivitually.
i.e. 10-0?-001-q?

I use the following script to generate the id's of posted fields.

Code: Select all

for ( $i = 1; $i <= 32; $i ++) {
if ($i > 9) {
$source="10-".$i."-001-q".$i;
}else{
$source="10-0".$i."-001-q".$i;
}

After that ... and there is the problem.... i create a string as follows

Code: Select all

$constract= "(isset(\$_POST['".$source. "'])) ? \$_POST['".$source."'] : \"\" ;" ;


With that way i suppose that i can check if the field has data in it or not.

Code: Select all

if (!$constract) {

echo "no data for field:" . $source;
}else{ 
echo "Field: " . $source . " has the following data: " . $constract; 
}


The problem here is that $constract variable does not store the value of the posted field but stores the hole string ....

Code: Select all

(isset($_POST['10-01-001-q1'])) ? $_POST['10-01-001-q1'] : "" ;

Code: Select all

(isset($_POST['10-02-001-q2'])) ? $_POST['10-02-001-q2'] : "" ;

.
.
.

I want to store the value of the posted field ..... and not the hole string ...


Can anyone help me ????
Thanks
sorry for my english

Posted: Thu Jan 19, 2006 9:53 am
by JayBird
Please edit you post and use the PHP code tags Image

????

Posted: Thu Jan 19, 2006 9:56 am
by brainpulse
what do you mean ?????

Posted: Thu Jan 19, 2006 9:58 am
by JayBird
Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]