title: Post email variable to PHP in iOS Xcode
body: <p>I am trying to post a variable from iOS Xcode to PHP. Below is my script, but the email variable will not post in my PHP:</p>
  
  <pre><code>php code $email_from = $_POST['email'];
  </code></pre>
  
  <p>Thinking <code>email</code> will come from iOS.</p>
  
  <p>Below is the Xcode:</p>
  
  <pre><code>    //Start of general request setup
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:serverLink]];
  [request setHTTPMethod:httpMethod];
  [request setTimeoutInterval:connectionTimeout];
  NSString *stringBoundary = [NSString stringWithString:@"0xKhTmLbOuNdArY"];
  NSString *contentType    = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", stringBoundary];
  [request addValue:contentType forHTTPHeaderField:@"Content-Type"];
  NSString *email =[NSString stringWithFormat:@"ryan"];
  //End of general request setup
  
  
  //Start of body setup
  NSArray *parametersKeys = [parameters allKeys];
  NSArray *imagesKeys = [images allKeys];
  
  NSMutableData *postBody = [NSMutableData data];
  [postBody appendData:[[NSString stringWithFormat:@"\r\n\r\n--%@\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
  BOOL addedData = NO;
  
  for (NSString *parameterKey in parametersKeys) {
      if (addedData) {
          [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
      }
      else {
          addedData = YES;
      }
      [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", parameterKey] dataUsingEncoding:NSUTF8StringEncoding]];
      [postBody appendData:[[NSString stringWithFormat:@"%@", [parameters objectForKey:parameterKey]] dataUsingEncoding:NSUTF8StringEncoding]];
  }
  
  for (NSString *imageKey in imagesKeys) {
      if (addedData) {
          [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
      }
      else {
          addedData = YES;
      }
      [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@.jpg\"\r\n", imageKey, imageKey] dataUsingEncoding:NSUTF8StringEncoding]];
      [postBody appendData:[@"Content-Type: image/jpeg\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
      [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; email=\"%@\"\r\n""", email] dataUsingEncoding:NSUTF8StringEncoding]];
      [postBody appendData:[images objectForKey:imageKey]];
  }    
  
  [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
  [request setHTTPBody:postBody];
  //End of body setup
  
  NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
  
  [parameters release];
  [images release];
  
  isSending = NO;
  </code></pre>