<?php

error_reporting(E_ERROR | E_PARSE);
// sql data connection 

$DB_Host = "localhost";
$DB_Name = "mrcode_FMdatabase";
$DB_Table = "workingOrder";
$DB_User = "mrcode_User";
$DB_Pass = "o;1fT@L+cB&P";


$forgeid =  $_GET['forgeid'];
$name = $_GET['name'];
$activity =  $_GET['activity'];
$urn = $_GET['urn'];
$week = $_GET['week'];

if($activity != null && $name != null){
    
    
// connect to sql 
$conn = new mysqli($DB_Host, $DB_User, $DB_Pass,$DB_Name);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// get data of element


    $sql = 'INSERT INTO `workingOrder`(`forge_id`, `name`, `Activity_id`, `urn`, `week`) VALUES (\'' . $forgeid . '\',\'' . $name . '\',\'' . $activity . '\',\'' . $urn . '\',\'' . $week . '\')';
    if ($conn->query($sql) === TRUE) {
        
        $myObj->INSERT = "OK";
        $myArray[] = $myObj;
        $myJSON = json_encode(array('workingOrder' =>$myArray));
        echo $myJSON;
        
    } 
    else {
        
        $myObj->INSERT = null;
        $myArray[] = $myObj;
        $myJSON = json_encode(array('workingOrder' =>$myArray));
        echo $myJSON;
    }
    

    


$conn->close();


}
else{
    
    $myObj->INSERT = null;
        $myArray[] = $myObj;
        $myJSON = json_encode(array('workingOrder' =>$myArray));
        echo $myJSON;
}

?>
