1

PHP Webサービスを使用して、JSON経由でログインを実行しようとしていますが、問題は常に出力が無効なユーザーになることです。

lementation LoginViewController
NSString *username;
NSString *password;
@synthesize arr,json;

- (IBAction)btnLogin:(id)sender {
        username=txtUserName.text;
        password=txtPassword.text;
    NSString *post = [NSString stringWithFormat:@"user_name=%@&user_password=%@",username,password];
        NSLog(@"post data value is:%@",post);
        NSString *hostStr =@"http://myjsonwork.com/working_apps/?";
        hostStr = [hostStr stringByAppendingString:post];


        NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:hostStr]];
        json=[NSJSONSerialization JSONObjectWithData:dataURL options:kNilOptions error:nil];

        NSString *str=[json objectForKey:@"success"];
        NSLog(@"post data value is:%@",hostStr);
        NSLog(@"post dataURL value is:%@",dataURL);


        if ([str isEqualToString:@"True"])
        {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Congrats" message:@"You are //authorised" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
        [alert show];

        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Invalid Username and password" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
            [alert show];
                    }
        }
4

0 に答える 0