title: Sending data to web form using POST from iPhone app
body: <p>I am trying to send data(a username and password) to an online form from my iPhone app using GET. </p>
  
  <p>This is my source code, but the problem is that no data gets stored in my database. </p>
  
  <pre><code>NSString *post =[[NSString alloc] initWithFormat:@"email=%@&amp;password=%@",enterUserName.text,enterPass.text];
  NSURL *url=[NSURL URLWithString:@"http://planetimpressions.com/contacts/imagecomm_register.php"];
  
  NSLog(post);
  NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
  
  NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
  
  NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
  [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];
  
  /* when we user https, we need to allow any HTTPS cerificates, so add the one line code,to tell teh NSURLRequest to accept any https certificate, i'm not sure about the security aspects
   */
  
  [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
  
  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>The source code of the web form is below. </p>
  
  <pre><code>if(isset($_GET['submit'])){
  $email = $_GET['email'];
  $password = $_GET['password'];
  $conn = mysql_connect("mysql", "*****", "*****");
  if(!$conn)
  {
    die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("imagecomm_users");
  $sql = "INSERT INTO registration(number, email, password) VALUES (null, 
  '$email', '$password')";
  if (!mysql_query($sql,$conn))
     {
    die('Error: ' . mysql_error());
    }
  }
  ?&gt;
  </code></pre>
  
  <p>I have tested the scripts and they work absolutely fine. I am able to store the username and password into a database using an online form. The only issue I am having is to connect to the online form from the app.</p>
  
  <p>I am not getting any error messages in the console or anything unexpected. Just, nothing happens. I will appreciate any help. Thanks</p>