POST and multiple submit buttons on form (iphone)
- by Jonathan
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)