HTML Form via POST method

Discussion in 'iOS Programming' started by satyam90, Sep 17, 2009.

  1. satyam90 macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #1
    I have an assignment before me. The description is as follows:

    There is a HTML form with 2 text fields and a submit button. When user enters data in 2 fields and presses "submit" button, the data will be sent to an ASP page. it process the data and displays true or false. The data is sent via "POST" method.

    Now I have to develop an application in iPhone that will do similar task.
    I tried NSURLConnection, ASIHTTPRequest etc. But couldn't succeed.

    Can some body show me some way to achieve this?
     
  2. drivefast macrumors regular

    Joined:
    Mar 13, 2008
    #2
    send a request to your asp page thru a proxy, and capture the request and the response, to have a real life sample of what you are trying to accomplish. read the iphone sdk documentation, the "URL Loading System" chapter. then use a NSMutableRequest with a POST http method, set the headers to reflect your sample, and then add your request string in the http body also as it is in your sample. it's really that simple.
     
  3. satyam90 thread starter macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #3
    Thanks drivefast, I understood the way of doing it. But while implementing, I'm not able to do it. If you have any example or tutorial, can you share it with me please
    --Satyam.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Where are you getting stuck? We can help better if you're more specific.
     
  5. qmank macrumors newbie

    Joined:
    Mar 6, 2011
    #5
    i am facing similar problem. I want to provide proxy host and port to url request. How to provide it in NSMutable request?

    thanks.
     
  6. KnightWRX, Mar 7, 2011
    Last edited: Mar 7, 2011

    KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #6
    Why can't you use a UIWebView and load this html file from a bundle ressource ?

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>form</title>
    </head>
    <body>
    <div>
    <form method="post" action="http://host.tld/url_to_post_to.asp">
     Field 1 : <input type="text" name="field1" />
     Field 2 : <input type="text" name="field2" />
    </form>
    </div>
    </body>
    </html>
    
    Just include the proper CSS and it'll look like a iPhone application.

    EDIT: wow, 2009 uh ? Should look before posting.
     

Share This Page