Problem with the POST method

Hello,
I have a problem with the POST method.
I describe the situation:
in Screen1 I log in with username and password and use the POST method.
It works perfectly.
f1
Once logged in, I switch to Screen2.
When in Screen2 I call any script, even the simplest, using the POST method, in the script I do not find the values ​​passed in the script (the $ _POST array is empty).
If I use the GET method instead it works perfectly.
I have tried in three different ways but the result is always the same.
1)
f2
2)


3)

Where am I wrong with?
Thanks

1 Like

Where are you getting “gobal path” from in Screen2?

I declare it in Screen2.
But it is the same path that I use with the GET method that works perfectly.
The script is executed but the global variable $ _POST is empty.
If I force a message I see it in the qElencoMedia.GotText.

I have tested this code on Screen1 and Screen2 and it works for me.

http://kio4.com/appinventor/326A_post_get.htm

Try a simple php:

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    
    $aa = $_POST['aa'];
    $bb = $_POST['bb'];
 
    echo $aa . "\n\n" . $bb;
}
?>

This should return the values for aa and bb in response content

I’ve already done it.
There is nothing.

If you are trying to receive a $POST_ARRAY, you are not sending one, you will have to construct a simple or associative array in the app before sending by POST.

If you only have a few parameters, it is easier to send as you have in the app, and receive each parameter to a variable - as per the two examples above - (or use directly)

The first case is like this.
But in the script the variables $ aa = $ _ POST [‘aa’] and $ bb = $ _ POST [‘bb’] are empty.
While if I use $ _GET they are valued.
I deduce that when I use the POST method there is some problem with passing values ​​…

After I set qElencoMedia.PostText text = ‘aa = 12 & bb = 34’ the two variables should arrive in the script.
But variables don’t really exist in the script.
Is there no way to see what the call goes through?
Something must happen that prevents the text from being sent.

should be $aa and $bb (no spaces) ?

yes no spaces

otherwise the script would go wrong …

you say… in Screen1 I log in with username and password and use the POST method.
It works perfectly.

Copy blocks qAccesso.url … access.php … qAccesso.Posttest in Screen2 to try

What is accesskey?

accesskey is a code that must be the same in the app and in the script. It could be used to avoid intrusions.
now I copy the inero instruction set of screen1 to screen2 and check

What do you have in your qElencoMedia.GotText block to handle the responseContent?

Notifier with url (that is correct) and ResponseCode (that is empty)

I have copied the same blocks for access to Screen2.
There is the same mistake. The variables in the script are null.

However, if I switch to the GET method it works correctly.

How do you know this, what are you checking on the server ?
It is easier to check the response content if you echo the values back....

You say you get nothing in responseCode?

I am running these blocks

image

to this php file

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    
    $aa = $_POST['aa'];
    $bb = $_POST['bb'];
 
    echo $aa . "\n\n" . $bb;
}
?>

and it works fine on Screen1 and Screen2 in my Companion App

Please test like this…

in the script I check the variable $ _POST [‘aa’] and it’s empty. It just doesn’t exist.
In the app I check the ResponseCode and it’s empty.
If in the script I do a ‘test’ echo. $ _POST [‘aa’] in ResponseContent I find only ‘test’