so i am using this code for a http request to the server to post the gps location of the user along with his username and password. it says connection sucessfull but i do not see anything on the server in the log at all
is there an issue with the code and is there anythig that i can add to the code which can help me weed out the issue
is there an issue with the code and is there anythig that i can add to the code which can help me weed out the issue
Code:
- (void)sendRequest {
NSString *userData = [[NSString alloc] initWithFormat:@"uid=%@&pw=%@&lat=%@&long=%@", usernameField.text, passwordField.text, currentLat, currentLong ];
NSString *post = [[NSString alloc] initWithFormat:@"%@%@", userData, [self getContacts]];
NSLog(post);
NSURL *url = [NSURL URLWithString:@"http://www.test.com/gps"];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (conn) {
NSLog(@"<---Connection successful--->");
}
else {
UIAlertView *noConnectionAlert = [[UIAlertView alloc] initWithTitle:@"Connection Failed" message:@"Sorry, your request could not be sent. Please check your internet connection and try again." delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[noConnectionAlert show];
[noConnectionAlert release];
}
}