title: Sending POST data from iphone over SSL HTTPS
body: <p>Hai all,</p>
  
  <p>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: localhost:8888/login?userName=admin&amp;password=password ) but now i need to sent this as a POST data, </p>
  
  <p>can any one help me to find what wrong in this code below ?</p>
  
  <p>code i tried ..</p>
  
  <hr>
  
  <pre><code>NSString *post =[NSString stringWithFormat:@"userName=%@&amp;password=%@",userName.text,password.text];
  
  NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
  
  NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
  
  NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
  [request setURL:[NSURL URLWithString:@"https://localhost:443/SSLLogin/login.php"]];
  [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:&amp;response error:&amp;error];
  NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
  NSLog(data);
  </code></pre>
  
  <p>this page will return success or failed using php echo </p>