| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- include_once "../../include/DB.php";
- $AssetID="";
- $AssetName="";
- $AssetCategoryID="";
- $IsInServiceCenter=1;
- if (isset($_POST["AssetID"]) && !empty($_POST["AssetID"])) {
- $AssetID=$_POST["AssetID"];
- }
- if (isset($_POST["AssetName"]) && !empty($_POST["AssetName"])) {
- $AssetName=$_POST["AssetName"];
- }
- if (isset($_POST["AssetCategoryID"]) && !empty($_POST["AssetCategoryID"])) {
- $AssetCategoryID=$_POST["AssetCategoryID"];
- }
- if (isset($_POST["IsInServiceCenter"]) && !empty($_POST["IsInServiceCenter"])) {
- $IsInServiceCenter=$_POST["IsInServiceCenter"];
- }
- $AssetInsertSql = "INSERT INTO asset(AssetID, AssetName, AssetCategoryID, IsInServiceCenter) VALUES ('$AssetID','$AssetName','$AssetCategoryID','$IsInServiceCenter')";
- $AssetInsertresult = $conn->query($AssetInsertSql);
- if ($AssetInsertresult === TRUE) {
- $value = array(
- "AssetID"=>$AssetID,
- "AssetName"=>$AssetName,
- "AssetCategoryID"=>$AssetCategoryID,
- "IsInServiceCenter"=>$IsInServiceCenter,
- "Message"=>"Data saved successfully",
- );
- // Use json_encode() function
- $json = json_encode($value);
- }else {
- http_response_code(404);
- $errorMesage= $conn->error;
- $value = array(
- "Message"=>"Something went wrong",
- "Error"=>$errorMesage
- );
- // Use json_encode() function
- $json = json_encode($value);
- }
- // Display the output
- echo ($json);
- $conn->close();
|