"post data to a php page from c# winform" Code Answer


i believe you need to properly encode and send the actual post content. it looks like you're just serializing into json, which php doesn't know what to do with (ie, it won't set it as $_post values)

string postdata = "firstname=" + httputility.urlencode(p.firstname) +
                  "&lastname=" + httputility.urlencode(p.lastname) +                    
                  "&email=" + httputility.urlencode(p.email) +
                  "&deviceuuid=" + httputility.urlencode(p.deviceuuid);
byte[] bytearray = encoding.ascii.getbytes(postdata);
// etc...

this should get your $_post variable in php set. later when you switch to json you could do something like:

string postdata = "json=" + httputility.urlencode(serializer.serialize(p) );

and grab from php:

$json_array = json_decode($_post['json']);
By Ellone on June 12 2022

Answers related to “post data to a php page from c# winform”

Only authorized users can answer the Search term. Please sign in first, or register a free account.