❔ HTTP code not returning expected result.
So I have the following code Which should send the following
http://zandose1.centralus.cloudapp.azure.com/test.php?Test1=Test2
and then I have some PHP code which should return Test1=Test2
. If I put http://zandose1.centralus.cloudapp.azure.com/test.php?Test1=Test2
into a browser it works fine but with the C# code it doesn't get the anything.15 Replies
You don't seem to ever be awaiting anything
I was having issues writing the code with awaiting so I got rid of them for testing.
Is it required to make it work?
It might be the cause of the issue, it might not be
But it's best to eliminate things that go against the proper usage first, makes finding actual errors easier
alright
I'll try rewriting it with awaits
So
I'm not familiar with PHP but in the C# code you are POSTing the form data and in the browser you are doing a GET request. How are you reading the values in your PHP code?
Thanks and done. Same result. Basically the PHP code takes the URL and returns it but it's only returning the
test
part.uh
That's the issue. The query string is everything after the ?. In a POST the data is sent as the body of the request.
You never send a query param named
QUERY_STRING
You send one named Test1
with the value Test2
Hmm
Also, get those values from the
$_GET
superglobal
Rule of thumb: don't use $_SERVER
$_GET
for query params, $_POST
for form bodyI was just testing by returning everything. I haven't made the PHP correct and secure yet.
OK, so this works
Just need to figure out how to add in the part
That's something you would read from
$_POST
$_POST['Test1']
to be preciseWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.