Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    240
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help with User ID

    Hi there
    I have a form where users can register. When they register, i would like to generate a user ID for them.

    what's the best way to do this?

    I thought that maybe I can create an ID field in the DB and have that be their user ID as it auto-increments? The thing is I don't know how to set the "minimum value" of this ID to be 8 digits.

    Thanks

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Normally it's better to let the user choose their user id and password. You can still require a certain format or minimum length for the user id and password and then you can just validate it when they submit it.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    240
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks Spookster...

    So in my DB, what would be the primary key for the users in my DB? Would it be the user ID they use?

    I figure that if I creat the user ID for them, I can sort things and organize things better in the DB.

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You could use the userid as the primary key or you could create a unique account number for every user and use that as the primary key and just associate the userid with that account number. As for sorting and organizing the data in the database you would only need to do something like that if you were going to generate a report with the user logins. The data in a database is generally not sorted and organized. When you query the database you can pull the data and sort it for whatever you are going to use it for. But in the case of logins I can't really see a need for that. Also if the database is well designed the login type data would be in a seperate table from all the other data. So if you use an account number associated with a user login to retrieve data on someone you would just need to do a lookup on the userid to retrieve the account number and once you have that you can pull of data from any of the other tables for that account.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •