943,582 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 6731
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 25th, 2007
0

Creating Login

Expand Post »
Hi I am having trouble creating a system to log in to a system.

If you look at a picture its like this. User selects thier user name from a dropdown box, and then select thier Picture(instead of typing in a password to login.

There can I get more info on how to make something like this?
Attached Thumbnails
Click image for larger version

Name:	Logindesign.JPG
Views:	78
Size:	18.3 KB
ID:	3095  
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
eeeman is offline Offline
27 posts
since Mar 2007
Mar 26th, 2007
0

Re: Creating Login

Do I store the usernames in an array lisst and pictures inb and array list and then somehow match them together to allow the user a succesful login>?
Reputation Points: 10
Solved Threads: 0
Light Poster
eeeman is offline Offline
27 posts
since Mar 2007
Mar 26th, 2007
0

Re: Creating Login

i would use a database myself
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
Mar 26th, 2007
0

Re: Creating Login

What language you wanna use? VB, VC, Java, JSP..
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Mar 26th, 2007
0

Re: Creating Login

Click to Expand / Collapse  Quote originally posted by eeeman ...
Do I store the usernames in an array lisst and pictures inb and array list and then somehow match them together to allow the user a succesful login>?
Now I saw the specific question. In my opinion you don't really need to "store the pictures". You can assign some ID to each picture and store the association of Username vs this ID. Picture could be just shown on the UI and when it's selected appropriate ID along with the username can be given to server for verification. (Point is you don't compare the picture with picture but ID with ID).
The ID can be an int or string or...
Storage of the list of Username vs ID most probably has to be done persistantly. I would recommend not to use DB if this is the only reason you want to use it. Rather go for a simple flat/txt file would be easier.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Mar 26th, 2007
0

Re: Creating Login

Click to Expand / Collapse  Quote originally posted by thekashyap ...
Storage of the list of Username vs ID most probably has to be done persistantly. I would recommend not to use DB if this is the only reason you want to use it. Rather go for a simple flat/txt file would be easier.
I don't know why you feel storing it in a flatfile is better. That requires that you load the entire list while running, or that you write your own search routines to search for the user/id combination. With a DB you simply set of a query with the username as the search string and return the "id". No fuss, no muss. No loading the entire list into main memory, and no self-rigged search routines. And storing new user/id combos is just as easy as finding one. A single statement, and you're done. And this includes the possibility of a new user attempting to use the same name as a current user, when the username is the primary key, as the insert will fail with a primary key validation. With that, you no longer even have to check yourself whether a new username exists or not. Simply try to add it.
Last edited by masijade; Mar 26th, 2007 at 7:49 am. Reason: typo
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Mar 26th, 2007
-1

Re: Creating Login

Click to Expand / Collapse  Quote originally posted by masijade ...
That requires that you load the entire list while running, or that you write your own search routines to search for the user/id combination.
True but I feel that would be easier !

Click to Expand / Collapse  Quote originally posted by masijade ...
With a DB you simply set of a query with the username as the search string and return the "id".
As someone quoted earlier you've deceptively missed a few other things:
1. Installation of DB?
2. Creation of DB table?
3. Code to create the DB connection?
4. Readup how to do step 1, 2 and 3 or ask someone???
I sure agree that once you're done with all this you'll "simply set of a query with the username as the search string and return the id".

Click to Expand / Collapse  Quote originally posted by masijade ...
No fuss, no muss. No loading the entire list into main memory, and no self-rigged search routines. And storing new user/id combos is just as easy as finding one. A single statement, and you're done.
Here is the fuss/muss we'll have to do if we use flat file (see the code at end). Self-regged search routines? std::map gives it. map::find().
Abt the "single stmt and you're done part" as I said earlier, it's not really true.

Click to Expand / Collapse  Quote originally posted by masijade ...
And this includes the possibility of a new user attempting to use the same name as a current user, when the username is the primary key, as the insert will fail with a primary key validation. With that, you no longer even have to check yourself whether a new username exists or not. Simply try to add it.
See the return type of std::map::insert(). It does this for you. Again you don't write no code.

C++ Syntax (Toggle Plain Text)
  1. #define MAX_LINE_LEN 100
  2.  
  3. int main()
  4. {
  5. FILE * pFile = fopen ("user_info.txt", "w+");
  6. if( ! pFile )
  7. {
  8. cout << "Could not open file" << endl ;
  9. return 1 ;
  10. }
  11.  
  12. for( int i = 0; i < 10; i++ )
  13. {
  14. char dummy[50] ;
  15. itoa(i, dummy, 10) ;
  16. fprintf (pFile, "%s %d\n", dummy, i);
  17. }
  18.  
  19. rewind (pFile);
  20.  
  21. map< string, int > usrInfMap ;
  22. char str [80];
  23. int j;
  24. while( EOF != fscanf (pFile, "%s %d", str, &j) )
  25. {
  26. usrInfMap[str] = j ;
  27. };
  28.  
  29. fclose (pFile);
  30.  
  31. map< string, int >::iterator it = usrInfMap.begin();
  32. for( ; it != usrInfMap.end(); it++ )
  33. cout << it->first.c_str() << " = " << it->second << endl ;
  34.  
  35. return 0;
  36. }

Now finally remember that I said earlier:
I would recommend not to use DB if this is the only reason you want to use it (=>DB).

Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Mar 26th, 2007
0

Re: Creating Login

Click to Expand / Collapse  Quote originally posted by thekashyap ...
True but I feel that would be easier !


As someone quoted earlier you've deceptively missed a few other things:
1. Installation of DB?
2. Creation of DB table?
3. Code to create the DB connection?
4. Readup how to do step 1, 2 and 3 or ask someone???
I sure agree that once you're done with all this you'll "simply set of a query with the username as the search string and return the id".


Here is the fuss/muss we'll have to do if we use flat file (see the code at end). Self-regged search routines? std::map gives it. map::find().
Abt the "single stmt and you're done part" as I said earlier, it's not really true.


See the return type of std::map::insert(). It does this for you. Again you don't write no code.

C++ Syntax (Toggle Plain Text)
  1. #define MAX_LINE_LEN 100
  2.  
  3. int main()
  4. {
  5. FILE * pFile = fopen ("user_info.txt", "w+");
  6. if( ! pFile )
  7. {
  8. cout << "Could not open file" << endl ;
  9. return 1 ;
  10. }
  11.  
  12. for( int i = 0; i < 10; i++ )
  13. {
  14. char dummy[50] ;
  15. itoa(i, dummy, 10) ;
  16. fprintf (pFile, "%s %d\n", dummy, i);
  17. }
  18.  
  19. rewind (pFile);
  20.  
  21. map< string, int > usrInfMap ;
  22. char str [80];
  23. int j;
  24. while( EOF != fscanf (pFile, "%s %d", str, &j) )
  25. {
  26. usrInfMap[str] = j ;
  27. };
  28.  
  29. fclose (pFile);
  30.  
  31. map< string, int >::iterator it = usrInfMap.begin();
  32. for( ; it != usrInfMap.end(); it++ )
  33. cout << it->first.c_str() << " = " << it->second << endl ;
  34.  
  35. return 0;
  36. }

Now finally remember that I said earlier:
I would recommend not to use DB if this is the only reason you want to use it (=>DB).

I did not miss any of those posts, but not asingle one of them is hard, and yna software you get will contain the instructions for doing them, so no, you would not need to "ask someone".

Everything else you wrote is c++ not Java. Go crawl back under the rock you came from.

And, flat file system will never give you the type of security you want for a password system unless you encrypt them as well. Then you also have to self-rigg that encryption system, and even though the "password" here is simply a picture "id" it should still be encrypted. Nearly all mainstream dbs provide an easy way to encrypt entries, so even that is "done for you".

So remember, I say again, why do you think a flat file system is better?
Last edited by masijade; Mar 26th, 2007 at 1:18 pm.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Mar 26th, 2007
0

Re: Creating Login

Wow is that coencidence that you both have avatars created by matt groening.

Ok, thnx for the replies aye. To be honest this doesnt even need security, all it really needs is different files stored for different userz.

I don't want to create a database so I like the flat txt file idea:-| .

Ill read through your comments and see if I can code this.
Reputation Points: 10
Solved Threads: 0
Light Poster
eeeman is offline Offline
27 posts
since Mar 2007
Mar 27th, 2007
0

Re: Creating Login

This is what I have so far. Btw im using J builder.

I've created the GUI and now I need to store the data when you Create Account.




java Syntax (Toggle Plain Text)
  1.  
  2.  
  3. //createAccountBtn pressed
  4. createAccountBtn.addActionListener(new ActionListener(){
  5. public void actionPerformed(ActionEvent e) {
  6. userName = userNameInput.getText();
  7. userBox.addItem(userName);
  8. }
  9. });

So far all I managed was to make the comboBox contain the username.
Reputation Points: 10
Solved Threads: 0
Light Poster
eeeman is offline Offline
27 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: help me please...............
Next Thread in Java Forum Timeline: creat a GUI solution





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC