Problem with the POST method

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’

It’s a test that I did too and it works. But in my initial it doesn’t work using the same instructions. I repeat, I think there is something that makes qElencoMedia.PostText work badly.
Now I do a test by erasing almost everything in Screen2 and I leave only the essentials.

Resolved!
In the path there was ‘http://mysite …’ instead of ‘http://www.mysite …’.
But with the GET method it worked. And when I switched to POST no.
I am sorry having you waste time. :disappointed:

The www in urls can be very confusing at times, especially in the way it is often handled in the browser address bar.

Glad you got there in the end. :+1:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.