My current code would be long winded and repetitive, is there any way that I can loop through the posted variables and check to see if they are set using the isset() function.
Here is my code:
$item_name = $_POST['item_name'];
$quantity = $_POST['qty'];
$model = $_POST['mdl'];
$weight = $_POST['wgt'];
$repornew = $_POST['ron'];
$date = $_POST['dob'];
$spec = $_POST['spc'];
$description = $_POST['desc'];
//retreive all values posted by user
if(isset($item_name) || isset($quantity) || isset($model) || isset($weight) || isset($repornew) || isset($date) || isset($spec) || isset($description)){
//send error back to user
}
Would using an array be a good idea, or even JSON to solve the problem?
I get the general idea of what I need to do, but what to use as the implementation is the thing that is bugging me.
Cheers
To loop through the POST variables and check if they were submitted: