0

In my application, I have login process and for that, I'm passing the username and password to php script and getting response. But the problem is, after getting the response I'm not able to move on to the next view controller or show the message.Need some guidance to resolve this issue.

This is my current code.

    - (IBAction)submit:(id)sender 
      {
         NSString *url = [NSString stringWithFormat:@"http://indianpoliticalleadersmap.com/IOS/login/getres.php?username=%@&password=%@",usern.text,pass.text];
         NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
         NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
         NSLog(@"%@",strResult);

         if ([strResult isEqualToString:@"succuss"]) 
         {
             UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Message" message:@"loged in" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
             [alert1 show];
             [alert1 release];
         }
      }

If I print the response, I can see the success message but still I don't why its not working.I am not able to make out where I'm going wrong in my above code.

Thanks.

jailani
  • 2,260
  • 2
  • 21
  • 45
user3793919
  • 13
  • 1
  • 10

1 Answers1

0

As I can see you are having two lines above your output so trim the string by \n and spaces.

    strResult=[strResult stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\n "]];

it will definetly work

iHulk
  • 4,869
  • 2
  • 30
  • 39