c# - Sending a string to a PHP page and having the PHP Page Display The String -
what i'm trying have php page display string i've created through function in c# application, via system.net.webclient.
that's it. in it' s simplest form, have:
webclient client = new webclient(); string url = "http://wwww.blah.com/page.php"; string testdata = "wooooo! test!!"; byte[] senddata = client.uploadstring(url, "post", testdata);
so, i'm not sure if that's right way it.. , i'm not sure how obtain string , display on php page. print_r(senddata) ??
any appreciated!
there 2 halves posting. 1) code posts page , 2) page receives it.
for 1) c# looks ok. use:
string url = "http://wwww.blah.com/page.php"; string data = "wooooo! test!!"; using(webclient client = new webclient()) { client.uploadstring(url, data); }
for 2) in php page:
if ( $_server['request_method'] === 'post' ) { $postdata = file_get_contents('php://input'); print $postdata; }
read reading post data in php here:
Comments
Post a Comment