Sunday, February 18, 2007

Http POST variables from C# to php

In php >= 4(so far i know) , developer can do set-get with POST variables in the following way

HTTP_POST_VARS['flakeIds'] = array('guid1','guid2','guid3');

This means you have array of guids in post vars, which has a element id named "flakeIds".Now, let's say someone gives you a php link that takes array of items, which you need to send from your C# code as confirmation or something like that.

Generally you will do a web request , with method type set to POST. This type of scenario , where it is necessary to pass array items over http POST,you should prepare your query string in the following way..

string params = "flakeids[]=1171722632&flakeids[]=1171723000";

byte [] bytes = System.Text.Encoding.ASCII.GetBytes(params);

Notice , just the same element name terminating with an "[]". Interesting huh.

Happy Coding!

1 comment:

Asif Ul Huque said...

i think php now gives $_POST, $_GET and $_REQUEST