Discussion Board

Results 1 to 3 of 3
  1. #1
    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
    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();
    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 !!


    But if do it this way instead:
    Code:
          String url = "myserver.com/read_username.php?username=brownd"
          HttpConnection hc = (HttpConnection)Connector.open(url, Connector.READ_WRITE);
          hc.setRequestMethod(HttpConnection.GET);
    The $_GET request is getting populated correctly.
    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 ?

  2. #2
    Super Contributor shmoove's Avatar
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    $_GET is only supposed to bring you parameters from the query string and $_POST from a url-encoded body. I'm not that good in PHP but I think that you need to use $_SERVER to get parameters from the http headers (doesn't matter if it's GET or POST).

    shmoove

  3. #3
    >> I'm not that good in PHP
    hmmm... I don't think so

    Thanks - that is it. It worked !!

Similar Threads

  1. [ help ] how to add cookie in http request header
    By cysnew in forum Symbian C++
    Replies: 6
    Last Post: 2008-05-15, 07:55
  2. How to send customized(none-standard) HTTP request headers?
    By trendin in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-06-02, 06:02
  3. HTTP Request Pipelining
    By shashishaw in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-08-25, 16:24
  4. Custom HTTP Header Name in POST Request
    By srigans1 in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-08-25, 06:56
  5. How can i solve this error?
    By symbian-newbie in forum Symbian C++
    Replies: 6
    Last Post: 2006-05-23, 05:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved