title: How to post data in the form of url in iOS?
body: <p>I want to send my UITextfields data to a server.</p>
  
  <p>I want to post data but the server showing error message to me.</p>
  
  <p>Please check my code:</p>
  
  <pre><code>  ...
  
    NSURL *url=[NSURL URLWithString:@"http://projectsatseoxperts.net.au/fishing/api/postRegister.php"];
  
    NSString *post =[[NSString alloc] initWithFormat:@"FirstName=%@&amp;LastName=%@userName=%@&amp;Email=%@Phone=%@&amp;Address=%@Password=%@&amp;ConfirmPassword=%@",
      txt_firstname.text,txt_lastname.text,txt_username.text,txt_email.text,txt_phone.text,txt_address.text,txt_password.text,txt_confirmpassword.text];
    NSLog(@"Post is: %@",post);
  
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSLog(@"postData is: %@",postData); 
  
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    NSLog(@"postLength is: %@",postLength);
  
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:url];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    //[request setValue:@"http://projectsatseoxperts.net.au/fishing/api/postRegister.php" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];
  
    NSLog(@"request is: %@", [request allHTTPHeaderFields]);
    NSError *error;
    NSURLResponse *response;
    NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
    NSLog(@"urlData is: %@",urlData);
  
    NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
    NSLog(@"%@",data);
  }
  </code></pre>
  
  <p>After post the details the values will come here - <a href="http://projectsatseoxperts.net.au/fishing/api/register.php" rel="nofollow">http://projectsatseoxperts.net.au/fishing/api/register.php</a></p>
  
  <p>Any idea or suggestions would be highly welcome.</p>