Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form processing $_POST to variables automatically

Tags:

php

I have about 40 items in my FORM and i'm trying to give all the Name= properties a variable for process without having to write each out manually. am I missing something here, cause the code below is not working. (name="comp1", name="comp2"... $comp1, $comp2)

$en = array_merge($em, $_POST);
$valid = true; 
foreach($_POST as $value) { 
    if(!isset($value)) { 
        $valid = false;
    } 
}
like image 849
acctman Avatar asked Aug 16 '12 11:08

acctman


1 Answers

If something is not in $_POST, the foreach will not loop through it. Isset() will always return true, because the foreach loops through all values in $_POST.

like image 94
Sjoerd Avatar answered Nov 08 '22 10:11

Sjoerd