Hi there,
I'm trying to set some custom fields into GET/POST request using HttpConnection. For example I want to pass in the user name to the server I tried this:
I got this sample code from somewhere
As you can see I'm setting a custom field in the GET request called "username". On the server php script I tried to read it from the $_GET request but it has nothing !!Code:String url = "myserver.com/read_username.php" HttpConnection hc = (HttpConnection)Connector.open(url, Connector.READ_WRITE); hc.setRequestMethod(HttpConnection.GET); hc.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT"); hc.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0"); hc.setRequestProperty("Content-Language", "en-CA"); hc.setRequestProperty("Connection","close"); hc.setRequestProperty("username", "brownd"); int rc = hc.getResponseCode();
But if do it this way instead:
The $_GET request is getting populated correctly.Code:String url = "myserver.com/read_username.php?username=brownd" HttpConnection hc = (HttpConnection)Connector.open(url, Connector.READ_WRITE); hc.setRequestMethod(HttpConnection.GET);
I tried POST request and it gives the same result.
What am I doing wrong here ?
How can set custom fields in GET/POST request ?

Reply With Quote


