projecte_ionic_entrega_02/backend/insert.php

24 lines
896 B
PHP

<?php
include "config.php";
$input = file_get_contents('php://input');
$data = json_decode($input, true);
$response = array();
$countryName = $data["countryName"];
$countryContinent = $data["countryContinent"];
$countryArea = $data["countryArea"];
$countryPopulation = $data["countryPopulation"];
$countryDrivingSide = $data["countryDrivingSide"];
$sqlQuery = "INSERT INTO `cs_countries` (`cs_country_id`, `cs_country_name`, `cs_country_continent`,";
$sqlQuery += " `cs_country_area`, `cs_country_population`, `cs_country_drivingSide`";
$sqlQuery += " VALUES (NULL, '$countryName', ' $countryContinent', $countryArea, $countryPopulation, '$countryDrivingSide')";
$sql = mysqli_query($con, $sqlQuery);
if($sql){
$response["message"] = "OK";
}else{
$response["message"] = "KO";
}
echo json_encode($response);
?>