Hai all,
In my iphone project i need to pass the user name and password to a web server,previously i pass data using GET method and used the url with GET format (eg:
Well, this exactly is not an answer to your question. But as an alternative, have a look at this code.I use this successfully for sending username and password to server.
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:loginURL]];
//set HTTP Method
[request setHTTPMethod:@"POST"];
//Implement request_body for send request here username and password set into the body.
NSString *request_body = [NSString stringWithFormat:@"Username=%@&Password=%@",[Username stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [Password stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
//set request body into HTTPBody.
[request setHTTPBody:[request_body dataUsingEncoding:NSUTF8StringEncoding]];
//set request url to the NSURLConnection
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(theConnection) //get the response and retain it
You can then implement the following delegate to check the response
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
Hope this helps.