您好我正在尝试使用php登录程序。
这是我的代码:
- (IBAction)login:(id)sender
{
if ([username.text isEqualToString:@""] || [password.text isEqualToString:@""]) {
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Input Your Value"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertsuccess show];
}
else {
NSError *err;
NSString *strURL = [NSString stringWithFormat:@"http://192.168.1.5:81/cer_app/cer_login.php?username=%@", username.text];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
manage.commonuser = username.text;
NSLog(@"%@", manage.commonuser);
NSString *bb = password.text;
NSDictionary *jsonArray = [NSJSONSerialization JSONObjectWithData:dataURL
options:kNilOptions
error:&err];
NSMutableArray *array1 = [[NSMutableArray alloc] init];
array1 = [jsonArray objectForKey:@"key"];
NSLog(@"%@", array1);
NSString *aa1 = [[array1 objectAtIndex:0]objectForKey:@"password"];
NSString *bb1 = [[array1 objectAtIndex:0]objectForKey:@"temp_password"];
if ([bb1 isEqualToString:@""]) {
if ([bb isEqualToString:aa1]) {
[self performSegueWithIdentifier:@"login" sender:self];
}
else {
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"password wrong"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertsuccess show];
}
}
else {
if ([bb isEqualToString:bb1]) {
[self performSegueWithIdentifier:@"temp_login" sender:self];
}
}
}
}
在这里,我从我的php获取了arrary1
值,并在控制台中显示,但我的performSegueWithIdentifier
无效。