I am sending data to the php file on the server using post using following code
NSString *post =[[NSString alloc] initWithFormat:@"UserName=%@&UserPassword=%@",appDelegate.userName,appDelegate.userPassword];
NSLog(@"post is %@",post);
NSURL *url=[NSURL URLWithString:@"http://ec2-50-94-162-129.compute-1.amazonaws.com/usercredential.php?"];
NSLog(@"URL is %@",url);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"%@",data);
data = [data stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"%@",data);
This shows login Failed if I access directly file from browser and provide userNAme in address then it works fine it does not work from iPhone app