When processing bulk form variables

Hey guys,

I’m currently processing 29 form variables in 1 form POST.
The information posted is not currently being run through a validation process. But I would like it to.
Can I validate the information without manually sending each $_POST variable to the validation function?

Some sort of loop that cycles through each $_POST and sending it to be checked.

Cheers.

[php]function updateBoard($id, $fastpost1, $fastpost2, $fastpost3, $staging5, $bcmoperator5, $bcmoperator6, $bcmoperator7, $bcmoperator8, $bcmoperator9, $bcmsweeper5, $bcmsweeper6, $bcmsweeper7, $bcmsweeper8, $bcmsweeper9, $tipper5, $tipper6, $tipper7, $tipper8, $tipper9, $culler5, $culler6, $culler7, $culler8, $culler9, $bcsoperator9, $bcssweeper9, $facingrejects7, $facingrejects9, $invstamp9) {

$data = array();
$data[1] = $fastpost1;
$data[2] = $fastpost2;
$data[3] = $fastpost3;
$data[4] = $staging5;
$data[5] = $bcmoperator5;
$data[6] = $bcmoperator6;
$data[7] = $bcmoperator7;
$data[8] = $bcmoperator8;
$data[9] = $bcmoperator9;
$data[10] = $bcmsweeper5;
$data[11] = $bcmsweeper6;
$data[12] = $bcmsweeper7;
$data[13] = $bcmsweeper8;
$data[14] = $bcmsweeper9;
$data[15] = $tipper5;
$data[16] = $tipper6;
$data[17] = $tipper7;
$data[18] = $tipper8;
$data[19] = $tipper9;
$data[20] = $culler5;
$data[21] = $culler6;
$data[22] = $culler7;
$data[23] = $culler8;
$data[24] = $culler9;
$data[25] = $bcsoperator9;
$data[26] = $bcssweeper9;
$data[27] = $facingrejects7;
$data[28] = $facingrejects7;
$data[29] = $invstamp9;

$i = 1;
for ($i=1; $i< 29; $i++) {
$this->validateData($data[$i]);
}
}[/php]

So at the moment I have this. Just wondering if there is a smarter way to build the array.

Ok, well here it is. This feels like a long way of doing it. Anyone have some suggestions on how else to do it?

[php] function updateBoard($id, $fastpost1, $fastpost2, $fastpost3, $staging5, $bcmoperator5, $bcmoperator6, $bcmoperator7, $bcmoperator8, $bcmoperator9, $bcmsweeper5, $bcmsweeper6, $bcmsweeper7, $bcmsweeper8, $bcmsweeper9, $tipper5, $tipper6, $tipper7, $tipper8, $tipper9, $culler5, $culler6, $culler7, $culler8, $culler9, $bcsoperator9, $bcssweeper9, $facingrejects7, $facingrejects9, $invstamp9) {
$data = array();
$data[1] = $tipper8;
$data[2] = $bcmsweeper8;
$data[3] = $bcmoperator8;
$data[4] = $culler8;
$data[5] = $tipper5;
$data[6] = $tipper6;
$data[7] = $tipper7;
$data[8] = $tipper9;
$data[9] = $staging5;
$data[10] = $fastpost1;
$data[11] = $fastpost2;
$data[12] = $fastpost3;
$data[13] = $bcmsweeper5;
$data[14] = $bcmsweeper6;
$data[15] = $bcmsweeper7;
$data[16] = $bcmsweeper9;
$data[17] = $bcmoperator5;
$data[18] = $bcmoperator6;
$data[19] = $bcmoperator7;
$data[20] = $bcmoperator9;
$data[21] = $culler5;
$data[22] = $culler6;
$data[23] = $culler7;
$data[24] = $culler9;
$data[25] = $bcsoperator9;
$data[26] = $bcssweeper9;
$data[27] = $facingrejects7;
$data[28] = $facingrejects7;
$data[29] = $invstamp9;

for ($i=1; $i<=29; $i++) {
$this->validateData($data[$i], $id, $i);
}
return true;
}

function validateData($person, $id, $i) {
$sql_text = “SELECT * FROM “.$this->TABLES[‘backup’].” WHERE id = ‘$id’”;
$data = $this->sql->Select($sql_text);
$len = count($data);
if($i == 2){ $boardpoint=8; $check=1; $this->BCMSweeperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 3){ $boardpoint=8; $check=1; $this->BCMOperatorChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 4){ $boardpoint=8; $check=1; $this->cullerChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 5){ $boardpoint=5; $check=1; $this->tipperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 6){ $boardpoint=6; $check=1; $this->tipperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 7){ $boardpoint=7; $check=1; $this->tipperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 8){ $boardpoint=9; $check=1; $this->tipperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 9){ $boardpoint=5; $check=1; $this->stagingChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 10){ $boardpoint=5; $check=1; $this->fastpostChecker($boardpoint,$person,$task=NULL,$n=NULL,$holder=NULL,$check); }
if($i == 11){ $boardpoint=5; $check=1; $this->fastpostChecker($boardpoint,$person,$task=NULL,$n=NULL,$holder=NULL,$check); }
if($i == 12){ $boardpoint=5; $check=1; $this->fastpostChecker($boardpoint,$person,$task=NULL,$n=NULL,$holder=NULL,$check); }
if($i == 13){ $boardpoint=5; $check=1; $this->BCMSweeperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 14){ $boardpoint=6; $check=1; $this->BCMSweeperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 15){ $boardpoint=7; $check=1; $this->BCMSweeperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 16){ $boardpoint=9; $check=1; $this->BCMSweeperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 17){ $boardpoint=5; $check=1; $this->BCMOperatorChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 18){ $boardpoint=6; $check=1; $this->BCMOperatorChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 19){ $boardpoint=7; $check=1; $this->BCMOperatorChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 20){ $boardpoint=9; $check=1; $this->BCMOperatorChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 21){ $boardpoint=5; $check=1; $this->cullerChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 22){ $boardpoint=6; $check=1; $this->cullerChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 23){ $boardpoint=7; $check=1; $this->cullerChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 24){ $boardpoint=9; $check=1; $this->cullerChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 25){ $boardpoint=9; $check=1; $this->BCSOperatorChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 26){ $boardpoint=9; $check=1; $this->BCSSweeperChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 27){ $boardpoint=7; $check=1; $this->facingRejectsChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 28){ $boardpoint=7; $check=1; $this->facingRejectsChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
if($i == 29){ $boardpoint=9; $check=1; $this->invStampChecker($boardpoint,$person,$task=NULL,$n=NULL,$check); }
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service