title: How to fetch data from server?
body: <p>I am making an login application in which user can log in.</p>
  
  <p>If the user has already register, then he should be able to log in with the same data saved on server and should be able to get alert view as success and if not the error alert.</p>
  
  <p>Unfortunately, I am not able to do that.</p>
  
  <p>Please help me out.</p>
  
  <p>This is my code:</p>
  
  <pre><code>-(IBAction)btn_login: (id) sender
  {
  
  NSString *firstname = Firstname.text;
  
  NSString *lastname = Lastname.text;
  
  NSString *post = [NSString stringWithFormat:@"fname=%@&amp;lname=%@",firstname,lastname];
  
  NSString *hostStr =@"http://www.yoursite.com/iphone.php";
  hostStr = [hostStr stringByAppendingString:post];
  NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:hostStr]];
  
  NSString *serverOutput = [[NSString alloc]initWithData:dataURL encoding:NSASCIIStringEncoding];
  
  if ([serverOutput isEqualToString:@"Yes"])
  {
      UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Congrats" message:@"You are authorised" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
      [alert show];
      [alert release];
  
  }
  else {
      UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Invalid Username and password" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
      [alert show];
      [alert release];
  }
  
  Firstname.text=nil;
  Lastname.text=nil;
  
  }
  </code></pre>
  
  <p>thanks</p>