I\'ll just keep this question short. What is wrong with my php code, it keeps outputting 0 or Required Field(s) is missing. Here\'s the code
Your error says it all. Since you get to the } else { ... }
bit, it means isset($_POST['id']) && isset($_POST['status_id'])
is false.
In other words, your form is either:
method="post"
to your <form>
tag. (actually, POST is default behaviour, so if this is the case, you probably have to remove or change method="GET"
from the form tag)name="id"
and/or name="status_id"
The updated question adds Android code. Hence this update:
I doubt that jsonParser.makeHttpRequest
actually posts a form encoded json string. It more then likely will just POST json data to the webserver. PHP's $_POST will not automatically be filled with this data, since it only handles form encoded data.
You probably need to read this data from stdIn.
Try:
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$rawPostData = file_get_contents("php://input");
$postData = (array)json_decode($rawPostData);
}
And then use $postData where you otherwise would use $_POST
Just debug the $_POST['id']
and $_POST['status_id']
.
Before this line.
if (isset($_POST['id']) && isset($_POST['status_id'])) {
you will find answer automatically. Hopefully one of two post variables is not set.
For debug use print_r($_POST);