Dark57 Posted April 7, 2010 Share Posted April 7, 2010 So I just got finished with writing my login/register script so that people can now log into the website. Now I want them to have there own account, similar to this website in a sense. When people register an account they must provide an ID, Username, Password, and Email. I want to know what is the best, most efficient way to figure out what their user ID is so that I can start recalling information from tables inside the database. This is a basic game text based game I am trying to develop if that helps you understand what I'm trying to accomplish. Link to comment https://forums.phpfreaks.com/topic/197921-user-ids-and-creating-accounts/ Share on other sites More sharing options...
Jax2 Posted April 7, 2010 Share Posted April 7, 2010 You don't want them setting their own ID, you want that to be done automatically via autoincrement in the MySQL table where you're storing their info. For example: table - users ID (int, 10, auto-increment, KEY) | username (varchar, 255, unique) | email (varchar, 255) | password (varchar, 255) And then when they sign in, it will set their USER ID (ID) to the next available number and that will always be their ID. Link to comment https://forums.phpfreaks.com/topic/197921-user-ids-and-creating-accounts/#findComment-1038569 Share on other sites More sharing options...
Jax2 Posted April 7, 2010 Share Posted April 7, 2010 Also, in your login script, when they log in, you can simply set their information into global session variables, such as: $_SESSION['userID']==$ID; (which you've gotten from a simple sql query looking up their username) $_SESSION['username']==$username; and then anywhere in your script, you can simply call them back like: echo "Hi ".$_SESSION['username'].", it's nice to see you again!"; Link to comment https://forums.phpfreaks.com/topic/197921-user-ids-and-creating-accounts/#findComment-1038571 Share on other sites More sharing options...
Dark57 Posted April 7, 2010 Author Share Posted April 7, 2010 Yeah I didn't mean they enter their own ID. I worded that wrong. Ok, so I can store all of this in a session. Thanks for the reply, time to tinker me some code. Link to comment https://forums.phpfreaks.com/topic/197921-user-ids-and-creating-accounts/#findComment-1038602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.