4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 PHP: Checking User
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Iyonix
WebHelper
WebHelper


Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England

PostPosted: Wed Mar 12, 2003 6:41 pm (14 years, 8 months ago) Reply with QuoteBack to Top

I have a mySQl table with a list of usernames and passwords in it. When a user registers I want it to check if a user of that name is allready in the database. How would I do this?

Regards,

________________________________
Iyonix
OfflineView User's ProfileFind all posts by IyonixSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Wed Mar 12, 2003 6:49 pm (14 years, 8 months ago) Reply with QuoteBack to Top

first select data from the database where the username = whatever the user requested as their username. Then use mysql_fetch_row() or mysql_fetch_array() to see if the result == NULL. if it does, then continue and create the account. if not, give the user an error.

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Wed Mar 12, 2003 6:55 pm (14 years, 8 months ago) Reply with QuoteBack to Top

Or you could do what adam suggested and then use mysql_num_rows to see if there is more than 0 rows...

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Wed Mar 12, 2003 7:02 pm (14 years, 8 months ago) Reply with QuoteBack to Top

thinking about it, I like daniel's idea better Very Happy using mysql_num_rows() would look neater.

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Iyonix
WebHelper
WebHelper


Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England

PostPosted: Wed Mar 12, 2003 7:07 pm (14 years, 8 months ago) Reply with QuoteBack to Top

Thanks Smile

________________________________
Iyonix
OfflineView User's ProfileFind all posts by IyonixSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.057137 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme