POST and multiple submit buttons on form (iphone)

Posted by Jonathan on Stack Overflow See other posts from Stack Overflow or by Jonathan
Published on 2010-05-05T19:16:11Z Indexed on 2010/05/05 19:18 UTC
Read the original article Hit count: 218

Filed under:
|
|
|
    NSString *reqURL = [NSString stringWithFormat:@"%@/login",SERVER_URL];

    NSMutableURLRequest *req = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:reqURL]];
    [req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];


    NSData *myRequestData = [NSData dataWithBytes:[@"username=whatever&password=whatever" UTF8String] length: [@"username=whatever&password=whatever" length]];
    [req setHTTPMethod: @"POST"];
    [req setHTTPBody: myRequestData];
    NSData *returnData = [NSURLConnection sendSynchronousRequest:req returningResponse: nil error: nil];
    NSString *html = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

I got this code from another question I asked. But what happens if there is more than one submit button. I really have no idea how to ask this question. An example of such situation is on the logout page for this site. There are no fields to enter data into, but there are 2 submit buttons.

How can I "simulate clicking" on one of those buttons using code like the above (so not using a UIWebView)

© Stack Overflow or respective owner

Related posts about post

Related posts about html