"Failture", "message" => "Database Connection Failed"]); return; } $jsonData =file_get_contents("php://input"); $data=json_decode($jsonData,true); if ($data === null) { http_response_code(400); // 回傳錯誤碼 400 Bad Request echo json_encode(["status" => "Failture","error" => "Invalid JSON"]); exit(); } // 取得POST傳入資料並進行防 SQL 注入處理 $Product_Key = CheckSQLCmd($data['Product_Key']); $MainUI = CheckSQLCmd($data['MainUI']); $Anatomy = CheckSQLCmd($data['Anatomy']); $Animal = CheckSQLCmd($data['Animal']); $Embryology = CheckSQLCmd($data['Embryology']); $CTRender = CheckSQLCmd($data['CTRender']); $Kinesiology = CheckSQLCmd($data['Kinesiology']); $Hisopathology = CheckSQLCmd($data['Histopathology']); $Radiology = CheckSQLCmd($data['Radiology']); $AI = CheckSQLCmd($data['Asclepius Intelligence']); $Abnormal = CheckSQLCmd($data['Abnormal']); // header('Content-Type: application/json'); // echo json_encode(["ssss"=>"123","ddd"=>$Product_Key,"ccc"=>$data['Hisopathology']]); // return; // 合併查詢PID與插入資料的SQL語句 $sql = "INSERT INTO Asclepius_Statistics (PID, MainUI_LT, Anatomy_LT, Animal_LT, Embryology_LT, CTRender_LT, Kinesiology_LT, Histopathology_LT, Radiology_LT, AI_LT, Abnormal_T) SELECT PID, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? FROM Asclepius_Product_Data WHERE Product_Key = ? ON DUPLICATE KEY UPDATE MainUI_LT = VALUES(MainUI_LT), Anatomy_LT = VALUES(Anatomy_LT), Animal_LT = VALUES(Animal_LT), Embryology_LT = VALUES(Embryology_LT), CTRender_LT = VALUES(CTRender_LT), Kinesiology_LT = VALUES(Kinesiology_LT), Histopathology_LT = VALUES(Histopathology_LT), Radiology_LT = VALUES(Radiology_LT), AI_LT = VALUES(AI_LT), Abnormal_T = VALUES(Abnormal_T)"; // 參數順序依照 SELECT 子句中的順序,最後一個參數為產品金鑰 $params = [ $MainUI, $Anatomy, $Animal, $Embryology, $CTRender, $Kinesiology, $Hisopathology, $Radiology, $AI, $Abnormal, $Product_Key ]; $mysql->sql_execute($sql, $params); // 回傳JSON訊息給客戶端 header('Content-Type: application/json'); echo json_encode(["status" => "success", "message" => "Statistics is Uploaded successfully"]); ?>