title: How to bring textfield value into other viewController in xcode Obj c?
body: <p>I have this <strong>email = 'abc'</strong> and <strong>pw = '123'</strong> value in PHP MySQL database and PHP code as below.</p>
  
  <p><strong>login2.php</strong></p>
  
  <pre><code>&lt;?php
  $connect = mysqli_connect("localhost","","","");
  if(isset($_POST['email'])) {
      $email = $_POST['email'];
      $pw    = $_POST['pw'];
      $sql   = "SELECT * FROM table WHERE email='$email' AND pw=md5('$pw')";
      $get   = mysqli_query($connect,$sql);
  
      if($get &amp;&amp; mysqli_num_rows($get) &gt; 0) {
          while($row = mysqli_fetch_assoc($get)) {
              $email_db = $row['email'];
              $pw_db    = $row['pw'];             
              echo '{"success":1}';
              exit();
          }
          mysqli_free_result($get);
      } else {
          echo '{"success":0}';
          echo mysqli_error($connect);
          exit();
      }
  }
  ?&gt;
  </code></pre>
  
  <p>What I want to achieve in xcode is to bring the <strong>success</strong> value into other ViewController called <strong>HomepageVC</strong> and display the value when loginbutton action is clicked. </p>
  
  <p>Right now i can only view the textfield value on the same ViewController page. I don't know how to transfer the input value into another ViewController. Obj c code as below. </p>
  
  <p><strong>ViewController.m</strong></p>
  
  <pre><code>@synthesize displayL,passL,email,pw;
  
  - (IBAction)loginbutton:(id)sender
  {    
      @try {
  
          if([[email text] isEqualToString:@""] || [[pw text] isEqualToString:@""] ) {
              [self alertFailed:@"Please enter both Username and Password" :@"Login Failed!"];
          }
          else {
              NSString *post =[[NSString alloc] initWithFormat:@"email=%@&amp;pw=%@",[email text],[pw text]];
              NSLog(@"PostData: %@",post);
              NSURL *url=[NSURL URLWithString:@"http://localhost/login2.php"];
              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/json" forHTTPHeaderField:@"Accept"];
              [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
              [request setHTTPBody:postData];
  
              NSError *error = [[NSError alloc] init];
              NSHTTPURLResponse *response = nil;
              NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
              NSLog(@"Response code: %d", [response statusCode]);
              if ([response statusCode] &gt;=200 &amp;&amp; [response statusCode] &lt;300)
              {
                  NSString *responseData = [[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
                  NSLog(@"Response ==&gt; %@", responseData);
                  SBJsonParser *jsonParser = [SBJsonParser new];
                  NSDictionary *jsonData = (NSDictionary *) [jsonParser objectWithString:responseData error:nil];
                  NSLog(@"%@",jsonData);
                  NSInteger success = [(NSNumber *) [jsonData objectForKey:@"success"] integerValue];
                  NSLog(@"%d",success);
                  if(success == 1)
                  {
                      NSLog(@"Login SUCCESS");
                      [self alertStatus:@"Logged in Successfully." :@"Login Success!"];
                      NSString * input  = email.text;
                      NSString * input2 = pw.text;
                      displayL.text = input;
                      passL.text = input2;
  
                  } else {
                      NSString *error_msg = (NSString *) [jsonData objectForKey:@"error_message"];
                      [self alertFailed:error_msg :@"Login failed"];
                  }
              } else {
                  if (error) NSLog(@"Error: %@", error);
                  [self alertFailed:@"Connection Failed" :@"Login Failed!"];
              }
          }
      }
      @catch (NSException * e) {
          NSLog(@"Exception: %@", e);
          [self alertStatus:@"Login Failed." :@"Login Failed!"];
      }
  }
  </code></pre>