Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-11-2011, 12:42 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Location: Ahmedabad
Posts: 25
nitingohel is on a distinguished road
Send a message via Skype™ to nitingohel
Post how to add Change password feature in Iphone Apps using Sqlite

Hi Friends..

I am trying to Add change password Feature in My iPhone applicaiton Using sqlite...

i have already done firs time insert password and save and login also...

In my change password View i take 3 UItextFiled

> First one for match Old password...
> second one is new password
> Third one is conformPassword

if old password match and new password and conform password also match then clicking on button and my old password will be updataed with new password please i am finding this solution last one week so please help

thank you friends my change password code below:-
Code:
-(IBAction)matchpassword{
	//sqlite3_stmt *updateStmt;
	sqlite3 *database;
	const char *dbpath = [databasePath UTF8String];
	sqlite3_stmt    *statement;
	
	if (sqlite3_open(dbpath, &database) == SQLITE_OK)
	{
		NSString *querySQL = [NSString stringWithFormat: @"SELECT password FROM password WHERE password=\"%@\"", txtOldPass.text];
		
		const char *query_stmt = [querySQL UTF8String];
		
		if (sqlite3_prepare_v2(database, query_stmt, -1, &statement, NULL) == SQLITE_OK)
		{
			if (sqlite3_step(statement) == SQLITE_ROW)
			{
				NSString *addressField = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
				if(updatepass == nil){
					if([txtNewPass.text isEqualToString:txtConfPass.text]){
						const char *sql ="update password Set password = ? Where pk = ?";
						
						if(sqlite3_prepare_v2(database, sql, -1, &updatepass, NULL)!=SQLITE_OK)
							NSAssert1(0,@"Error while creating update statement. '%s'.",sqlite3_errmsg(database));
					}
					
				//	Globle *objupdate = [[Globle alloc]initWithPK:0];
				//	objupdate.pass =[[NSString stringWithUTF8String:(char *)sqlite3_column_text(updatepass, 1)]retain];
					//pass = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(login, 1)]retain];
					sqlite3_bind_text(updatepass, 1, [pass UTF8String], -1, SQLITE_TRANSIENT);
					sqlite3_bind_int(updatepass, 2, pk);
					

					
					if(SQLITE_DONE != sqlite3_step(updatepass)){
						NSAssert1(0,@"error while updating  '%s'",sqlite3_errmsg(database));
					}
					else{
						sqlite3_last_insert_rowid(database);
					}
					sqlite3_reset(updatepass);
					sqlite3_finalize(updatepass);
					[objectToEdit setValue:txtOldPass forKey:self.keyOfTheFieldToEdit];
					passwordViewController *FBController = [[passwordViewController alloc] initWithNibName:@"passwordViewController" bundle:nil];
					[self.view addSubview:FBController.view]; 
					
				}
				txtOldPass.text = addressField;
				status.text = @"Match found";
				[addressField release];
			}
			else 
			{
				//status.text = @"Match not found";
				txtOldPass.text = @"";
				//phone.text = @"";
				UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Wrong username or password" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
				[alert show];
				[alert release];
				
			}
			sqlite3_finalize(statement);
		}
		sqlite3_close(database);
	}
	
}

Last edited by nitingohel; 11-11-2011 at 03:10 AM.
nitingohel is offline   Reply With Quote
Old 11-11-2011, 01:32 AM   #2 (permalink)
Registered Member
 
mouser58907's Avatar
 
Join Date: Feb 2010
Posts: 188
mouser58907 is on a distinguished road
Default

1. Please wrap code in [ CODE ] ... [ /CODE ] tags.

2. You should use the keychain for securely storing username and passwords.
iphone - iOS: How to store username/password wihtin an app? - Stack Overflow

3. If you choose not to use the keychain, you should bind parameters on your select statement as well. This line is very wrong.
Code:
NSString *querySQL = [NSString stringWithFormat: @"SELECT password FROM password WHERE password=\"%@\"", txtOldPass.text];
You should select the password by the userid and then make sure they match.

I'm not sure what your question is beyond these problems. Is it not saving to the database?
__________________
My Apps:Pee Prank (free)
My Company: Pulsar Productions

If I helped you, download my App or tell a friend! Thanks.
mouser58907 is offline   Reply With Quote
Old 11-11-2011, 03:07 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Location: Ahmedabad
Posts: 25
nitingohel is on a distinguished road
Send a message via Skype™ to nitingohel
Default

Quote:
Originally Posted by mouser58907 View Post
1. Please wrap code in [ CODE ] ... [ /CODE ] tags.

2. You should use the keychain for securely storing username and passwords.
iphone - iOS: How to store username/password wihtin an app? - Stack Overflow

3. If you choose not to use the keychain, you should bind parameters on your select statement as well. This line is very wrong.
Code:
NSString *querySQL = [NSString stringWithFormat: @"SELECT password FROM password WHERE password=\"%@\"", txtOldPass.text];
You should select the password by the userid and then make sure they match.

I'm not sure what your question is beyond these problems. Is it not saving to the database?



thank you sir..
i am storing my password in database i just want to change my old password for example we mostly see in website...

Last edited by nitingohel; 11-11-2011 at 03:25 AM.
nitingohel is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone change password, sqlite

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 404
17 members and 387 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, chiataytuday, dre, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, mbadegree, n00b, pbart, Retouchable, Sami Gh, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:23 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0