hi i am building a site where people will log in and get access to there user area.
they will have to register first and i was thinking about using the session id that they had to register with as their unique user id is this a sound idea or just maddness.
my thinking is that all session id's should be unique as they are generated from the system time.
if this is not a good idea does anyone have any ideas how i can generate a unique user id?
Thanks all
Unique user ID
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Unique user ID
You would generally use an auto incremented id in your users table to serve as their "unique id".
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Unique user ID
think so tooJohn Cartwright wrote:You would generally use an auto incremented id in your users table to serve as their "unique id".
Re: Unique user ID
In order to make it auto increment you will need to select it as your Primary Key or it will throw an error. I took an hour trying to figure that out to start with ;P
Re: Unique user ID
Hi dedicated kid!
lets see what wee can do. If you want to generate a unique id (I think you want your users to have different IDs).
1)Ok first of all you would have to save your users IDs in database.
2)Whenever your people create a new user, it should be checked in the database, IF the ID already exists it should not be Inserted into Database. ELSE IF the ID is not created, it can be inserted into Database Table.
For this create a connection and fill up an array, if it gets filled up, it means database has entry of same ID, otherwise its an new entry.
Ex:
$db = mysql_connect( "localhost", "root", "" );
mysql_select_db( "myTable", $db )
$sql='SELECT * FROM myTable';
$result=mysql_query($sql,$db);
$rows=mysql_fetch_array(result);
lets see what wee can do. If you want to generate a unique id (I think you want your users to have different IDs).
1)Ok first of all you would have to save your users IDs in database.
2)Whenever your people create a new user, it should be checked in the database, IF the ID already exists it should not be Inserted into Database. ELSE IF the ID is not created, it can be inserted into Database Table.
For this create a connection and fill up an array, if it gets filled up, it means database has entry of same ID, otherwise its an new entry.
Ex:
$db = mysql_connect( "localhost", "root", "" );
mysql_select_db( "myTable", $db )
$sql='SELECT * FROM myTable';
$result=mysql_query($sql,$db);
$rows=mysql_fetch_array(result);