當點擊更新按鈕,然後數據不更新,我想剛剛更新了我的密碼invalide用戶名或密碼時驗證它的sqlite iphone
第一場比賽的舊密碼 如果與數據庫中的舊密碼匹配,則驗證新密碼並使用isEquelToString然後點擊更新按鈕順應密碼,舊密碼必須NEWPASSWORD
當點擊更新按鈕,然後數據不更新,我想剛剛更新了我的密碼invalide用戶名或密碼時驗證它的sqlite iphone
第一場比賽的舊密碼 如果與數據庫中的舊密碼匹配,則驗證新密碼並使用isEquelToString然後點擊更新按鈕順應密碼,舊密碼必須NEWPASSWORD
我認爲,用戶名和密碼匹配單個用戶只有在那裏,如果再搭配它會使用下面的代碼返回一行進行更新。檢查下面的代碼,我認爲這將適用於你。
-(void)checkingDatabase{
databaseName = @"trylogin.sqlite";
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [[documentsDir stringByAppendingPathComponent:databaseName]retain];
NSLog(@"databse path %@",databasePath);
database = nil;
int myInt = 0;
if(sqlite3_open([databasePath UTF8String], &database) ==SQLITE_OK){
NSString *sql = [[NSString alloc] initWithFormat:@"select COUNT(*) from loginTry where userName='%@' and password='%@'",txtusername.text,txtPassword.text];
const char *sqlStatement = [tempSQL cStringUsingEncoding:NSUTF8StringEncoding];
[tempSQL release];
sqlite3_stmt *compiledStatement;
sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL);
if(sqlite3_step(compiledStatement) == SQLITE_ROW) {
myInt = (int)sqlite3_column_int(compiledStatement, 0);
}
sqlite3_finalize(compiledStatement);
sqlite3_close(database);
}
if(myInt ! = 0){
AnimalViewController *FBController = [[AnimalViewController alloc] initWithNibName:@"AnimalViewController" bundle:nil];
[self.view addSubview:FBController.view];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Wrong username or password" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
非常感謝你,我做了它,但現在我正在創建更改密碼控制...首先我匹配舊密碼,然後第二個文本提交是新密碼,第三是符合密碼我匹配舊密碼但不能更新新的密碼任何想法...? – nlg
您是在成功登錄後還是在登錄應用程序之前實現此功能? – HiddenDeveloper
在我的應用程序中,我成功插入數據並登錄太多,現在我把一個按鈕(更改密碼)在登錄視圖中,並通過點擊按鈕用戶重定向更改密碼查看和我在這裏實現這個功能,像第一個舊密碼必須匹配第一個textFild 然後如果新密碼和符合密碼都匹配,那麼新密碼將通過點擊當前數據庫中的按鈕(更新)來更新,我希望你明白我在說什麼......? – nlg
如上相同的,但在某些條件下改變檢查如下..
if(myInt ! = 0) {
if([newpassword.text isEqualToString: confirmPassword.text]) {
//Write code for update query.
}
else {
//print message new password and confirm password does not match.
}
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Wrong username or password" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
我只是除了你今天的答案對不起延遲.. :) – nlg
@hello尼廷,我沒有在我的回答讓您的代碼。它在哪裏? – HiddenDeveloper
檢查主要問題我adit並把代碼 – nlg