<?php
  
// input data through array
 $input=$_GET['q'];

 if($input=='turn left'||$input=='light'){
 	$status='left';

 }else if($input=='turn right'){
 	$status='right';
 }else if($input=='forward'||$input=='move front'||$input=='go straight'||$input=='up'){
 	$status='up';
 }elseif ($input=='backward'||$input=='download'||$input=='go back'||$input=='go bag') {
 	$status='down';
 }elseif ($input=='stop') {
 	$status='stop';
 }elseif ($input=='fan on'||$input=='turn on'||$input=='phone on'){
 	$status2='on';
 }elseif ($input=='fan off') {
 	$status2='off';
 }elseif($input=='light on'){
 	$status1='on';
 }elseif($input=='light off'){
 	$status1='off';
 }




 else{
 	echo ("<script LANGUAGE='JavaScript'>
    window.alert('Please Provide Exact Word');
    </script>");
 }
$array = Array (
  
    "light" => $status1,
    "fan" => $status2,
    "wheel"   => $status
    
    
  
);

// encode array to json
$json = json_encode($array);

file_put_contents("light.json", $json);
header('location:index.php');

?>
