PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
to answer your question, select the user id from the database, the save that value in the session array also. but dont you think its a very bad idea for the usernames to not be unique?!
Thanks for the quick response liljester. I did think this would be the way to do it. Just I often find it hard laying the code out.
I did wonder about the username problem, but after searching after a tutorial with no success. I thought tis would be a suitable option. If anyone could point me in the right direction for one that would be great.
That confirmed the code I tried earlier. It should work but for some reason on the other pages. It doesn't I have changed all the SESSIONS to match but no joy.
try replaceing $row['id'] with something static... like 'testing'. then echo out $_SESSION['userID'] to see if it shows 'testing' if it does then you know that $row['id'] isnt returning a usable value.
am assuming you have a signup page of some sort... and you process those post variables to add the user to the database.
before you add the user details to the database... add a check to see if the chosen username exists (just like the DB query you are using to check the username and password below). if it does then go ahead and input the data to the database... if not then return an error to the user saying he/she needs to choose a new username.