Advertisement
Guest User

Untitled

a guest
May 19th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.11 KB | None | 0 0
  1. - (IBAction)btnSave:(id)sender {
  2.  
  3.  
  4. Pheptoan *functionStr = [[Pheptoan alloc] init];
  5.  
  6. NSInteger success=0;
  7.  
  8. @try{
  9. if([[self.txtUsername text] isEqualToString:@""] || [[self.txtPassword text] isEqualToString:@""] || [[self.txtEmail text] isEqualToString:@""]
  10. || [[self.txtName text] isEqualToString:@""]|| [[self.txtTel text] isEqualToString:@""]){
  11. [self showUIAlertWithMessage:@"User/Email not blank n Password not blank" andTitle: @"Message"];
  12. }else{
  13.  
  14. NSString *password = _txtPassword.text;
  15.  
  16. NSData *passwordData = [password dataUsingEncoding:NSUTF8StringEncoding];
  17.  
  18. NSString *passwordMD5 = [functionStr MD5:passwordData];
  19.  
  20.  
  21. NSString *userUrl = [NSString stringWithFormat:@"http://ios.khothe.vn/web/gamecard/register/sUsername/%@/sPassword/%@/sName/%@/sEmail/%@/sTel/%@", _txtUsername.text, passwordMD5,_txtName.text,_txtEmail.text,_txtTel.text];
  22.  
  23. NSLog(@"link: %@", userUrl);
  24.  
  25. NSURL *url = [NSURL URLWithString:userUrl];
  26.  
  27. NSURLRequest *request=[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30.0];
  28.  
  29.  
  30. NSError *error = nil;
  31. NSHTTPURLResponse *response;
  32. NSData *data= [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
  33. if (!data) {
  34. NSLog(@"Error: %@", [error localizedDescription]);
  35.  
  36. }
  37.  
  38. if([response statusCode]>=200 && [response statusCode]<300){
  39.  
  40. NSError *error= nil;
  41.  
  42. NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
  43.  
  44. success = [[jsonDictionary valueForKey:@"success"] integerValue];
  45.  
  46. if(success == 400){
  47. [self showUIAlertWithMessage:@"sucessfull" andTitle:@"Message"];
  48.  
  49. }else{
  50. [self showUIAlertWithMessage:@"Error! Please wrong username or password" andTitle:@"Message"];
  51. }
  52.  
  53. }
  54.  
  55. }
  56. }@catch(NSException *e){
  57. [self showUIAlertWithMessage:@"Error! Please login again" andTitle:@"Message"];
  58.  
  59. }
  60.  
  61. if(success == 400){
  62. [self performSegueWithIdentifier:@"loginSuccess" sender:self];
  63.  
  64. }
  65.  
  66.  
  67. }
  68.  
  69. public function actionRegister()
  70. {
  71. $connection = Yii::app()->dbgamecard;
  72. if($_GET != null){
  73. $sUsername = $_GET["sUsername"];
  74. $sPassword = $_GET["sPassword"];
  75. $sName = $_GET["sName"];
  76. $sEmail = $_GET["sEmail"];
  77. $sTel = $_GET["sTel"];
  78.  
  79. $userInfo = Yii::app()->dbgamecard->createCommand("SELECT Username FROM member WHERE Username=:sUsername")
  80. ->bindParam(':sUsername', $sUsername)
  81. ->queryRow();
  82. $arr = null;
  83. if($userInfo){
  84. echo json_encode(array("success" => 404));
  85. //$arr["Status"] = "0";
  86. //$arr["Message"] = "Username Exists!";
  87. //echo json_encode($arr);
  88. exit();
  89. }
  90.  
  91. $userInfo = Yii::app()->dbgamecard->createCommand("SELECT Email FROM member WHERE Email=:sEmail")
  92. ->bindParam(':sEmail', $sEmail)
  93. ->queryRow();
  94.  
  95. if($userInfo){
  96. echo json_encode(array("success" => 404));
  97. //$arr["Status"] = "0";
  98. //$arr["Message"] = "Email Exists!";
  99. //echo json_encode($arr);
  100. exit();
  101. }
  102. $strSQL = "INSERT INTO member (Username,Password,Name,Email,Tel)
  103. VALUES(:strUsername, :strPassword, :strName, :strEmail, :strTel)";
  104. $command= $connection->createCommand($strSQL);
  105. $command->bindParam(":strUsername", $sUsername,PDO::PARAM_STR);
  106. $command->bindParam(":strPassword", $sPassword,PDO::PARAM_STR);
  107. $command->bindParam(":strName", $sName,PDO::PARAM_STR);
  108. $command->bindParam(":strEmail", $sEmail,PDO::PARAM_STR);
  109. $command->bindParam(":strTel", $sTel,PDO::PARAM_STR);
  110. $command->execute();
  111. if(!$command)
  112. {
  113. echo json_encode(array("success" => 404));
  114. //$arr["Status"] = "0";
  115. //$arr["Message"] = "Cannot Save Data!";
  116. //echo json_encode($arr);
  117. exit();
  118. }
  119. else{
  120. $userInfo1['success'] = 400;
  121. echo json_encode($userInfo);
  122. //$arr["Status"] = "1";
  123. //$arr["Message"] = "Register Successfully!";
  124. //echo json_encode($arr);
  125. exit();
  126. }
  127. }
  128. mysql_close($objConnect);
  129. }
  130. }
  131.  
  132. 2016-05-19 17:17:19.738 gamecard App[1608:126645] -[RegisterController hideKeyboard:]: unrecognized selector sent to instance 0x7fdbbb645560
  133. 2016-05-19 17:17:19.742 gamecard App[1608:126645] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RegisterController hideKeyboard:]: unrecognized selector sent to instance 0x7fdbbb645560'
  134. *** First throw call stack:
  135. (
  136. 0 CoreFoundation 0x0000000103164d85 __exceptionPreprocess + 165
  137. 1 libobjc.A.dylib 0x000000010284fdeb objc_exception_throw + 48
  138. 2 CoreFoundation 0x000000010316dd3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
  139. 3 CoreFoundation 0x00000001030b3cfa ___forwarding___ + 970
  140. 4 CoreFoundation 0x00000001030b38a8 _CF_forwarding_prep_0 + 120
  141. 5 UIKit 0x00000001045c6b28 _UIGestureRecognizerSendTargetActions + 153
  142. 6 UIKit 0x00000001045c319a _UIGestureRecognizerSendActions + 162
  143. 7 UIKit 0x00000001045c1197 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 843
  144. 8 UIKit 0x00000001045c9655 ___UIGestureRecognizerUpdate_block_invoke898 + 79
  145. 9 UIKit 0x00000001045c94f3 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 342
  146. 10 UIKit 0x00000001045b6e75 _UIGestureRecognizerUpdate + 2634
  147. 11 UIKit 0x000000010414348e -[UIWindow _sendGesturesForEvent:] + 1137
  148. 12 UIKit 0x00000001041446c4 -[UIWindow sendEvent:] + 849
  149. 13 UIKit 0x00000001040efdc6 -[UIApplication sendEvent:] + 263
  150. 14 UIKit 0x00000001040c9553 _UIApplicationHandleEventQueue + 6660
  151. 15 CoreFoundation 0x000000010308a301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
  152. 16 CoreFoundation 0x000000010308022c __CFRunLoopDoSources0 + 556
  153. 17 CoreFoundation 0x000000010307f6e3 __CFRunLoopRun + 867
  154. 18 CoreFoundation 0x000000010307f0f8 CFRunLoopRunSpecific + 488
  155. 19 GraphicsServices 0x0000000107ae5ad2 GSEventRunModal + 161
  156. 20 UIKit 0x00000001040cef09 UIApplicationMain + 171
  157. 21 gamecard App 0x00000001022bda9f main + 111
  158. 22 libdyld.dylib 0x000000010626192d start + 1
  159. 23 ??? 0x0000000000000001 0x0 + 1
  160. )
  161. libc++abi.dylib: terminating with uncaught exception of type NSException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement