Using the code found here I am posting input fields to a php script. The result looks something like this
data:{
"textfield": ["",""],
"dropdown": ["option1","option1"],
"siteTitle":"this is the site title",
"siteKey":"",
"siteurl":"",
"address1":"",
"address2":"",
"address3":"",
"landline":"",
"method":"addSite",
"small-input":"",
"medium-input":"",
"large-input":""
}
I am picking off each field using the following.
$data = $_POST['data'];
$data =stripslashes($data);
$obj = json_decode($data);
$siteTitle = sanitize($obj->siteTitle);
if (!$siteTitle){echo json_encode(array("msg"=> "Site title missing"));break;}
Is there a way in php to automatically step thru each posted field
and assign it to a variable based on the name
?
for those concerned about Déjà vu, don't be.