A user inputs values into a form on a Raspberry Pi and this should, in theory, convert the values to json format, write it to file, kill all of my bp sessions and start again (with a redirect to BBC as confirmation for now).
The parameters tail, growthrate, and fps are being encoded as strings, not integers. The result in the final file (webtest1.json) is that they appear as "tail": "1" and I need "tail": 1.
// check if a form was submitted
if( !empty( $_POST ) ){
// convert form data to json format
$postArray = array(
"driver" => $_POST['driver'],
"animation" => array(
"typename" => $_POST["typename"],
"tail" => $_POST["tail"],
"growthRate" => $_POST["growthRate"]
),
"run" => array(
"fps" => $_POST["fps"]
),
"layout" => $_POST['layout']
);
//you might need to process any other post fields you have..
$json = json_encode( $postArray );
// make sure there were no problems
//if( json_last_error() != JSON_ERROR_NONE ){
//exit; // do your error handling here instead of exiting
// }
$file = '/home/pi/Documents/webtest1.json';
// write to file
// note: _server_ path, NOT "web address (url)"!
file_put_contents( $file, $json);
}
shell_exec("sudo killall bp");
shell_exec("sudo bp /home/pi/Documents/webtest1.json > /dev/null 2>/dev/null &");
header("Location: http://www.bbc.co.uk");
die();
pi.