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, 
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth- 

$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 . " 

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);

People are also looking for solutions to the problem: html - how to fetch a page's likes from fb by php


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.