rest - Posting Data from Ionic App to PHP-File on Webserver via POST wont work
right now im trying to send datat from my ionic app to a php-file which should use that data for a MySQL-statement. unfortunately the file cant access the data and since im kinda new to HTTP-Requests i dont know why. As far as i can see the request is a valid one.
Below u can see my php code.
i Hope you can help
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE,
OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-
Token');
$postdata = file_get_contents("php://input");
$argument = json_decode($_POST["argument"]);
$mysqli = new mysqli(//DB connection is set here);
$query = $argument;
$dbresult = $mysqli->query($query) or trigger_error($mysqli->error . "
[$query]");
while ($row = $dbresult->fetch_array()) {
$json_row = $row['num'];
}
if ($dbresult) {
$result = $json_row;
}
else {
$preresult = "{'success':false}";
$result = json_encode($preresult);
}
echo json_encode($json_row);