paulferree Posted February 14, 2008 Share Posted February 14, 2008 You guys were so awesome & quick on my last question I figured I'd let you field another one! :-) What is the best method/logic (I don't necessarily need the code) for checking to see if a username already exists in a database table? I have a feeling it's a lot easier than what I'm thinking. Would I do a query: SELECT username FROM table WHERE username = $username and if it produced and error (or is not found) go ahead and create the record...if the query actually resolves then display a message saying the user already exists. Is that right? Paul Link to comment https://forums.phpfreaks.com/topic/91146-best-way-to-check-if-a-user-already-exists/ Share on other sites More sharing options...
rhodesa Posted February 14, 2008 Share Posted February 14, 2008 Yup, that is exactly what you would do. As long as the syntax is good, the query won't produce an error if the username doesn't exist, it will just return an empty set. Link to comment https://forums.phpfreaks.com/topic/91146-best-way-to-check-if-a-user-already-exists/#findComment-467140 Share on other sites More sharing options...
paulferree Posted February 14, 2008 Author Share Posted February 14, 2008 Great! I'm on a roll. hahaha... Thanks, Paul Link to comment https://forums.phpfreaks.com/topic/91146-best-way-to-check-if-a-user-already-exists/#findComment-467148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.