ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 13th, 2004, 10:23 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 183 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 16 h 46 m 44 sec
Reputation Power: 0
Exclamation Dont repeat username

Im creating an application that requires a person to login with a username and password before they use it. They get to choose their own username by a form that CFINPUTs it in the database. I need a code that will not allow usernames to be repeated. In other words that no 2 people have the same username.

thanks

Reply With Quote
  #2  
Old July 14th, 2004, 08:50 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
When the user submits the form, just query the database and make sure the same user name isn't already in the table. If it isn't, proceed. If it is, redisplay the form with an error message.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old July 14th, 2004, 09:29 AM
adrapley adrapley is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Washington DC, USA
Posts: 20 adrapley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Keep this in mind

Depending on what database platform you're using, data in the db may be case sensitive. Keep this in mind when working with usernames. You may want to store them in the database either as upper or lower case strings.

e.g.

<cfquery datasource="#datasource#">
INSERT INTO users (username)
VALUES ('#LCase(form.username)#')
</cfquery>

then when you query the data from the database, you can reference like the following

<cfquery name="qryUsers" datasource="#datasource#">
SELECT username
FROM users
WHERE username = '#LCase(form.username)#'
</cfquery>

This will help ensure you don't get usernames mixed up.

Also, you may also want to place a UNIQUE contraint on the username field to give that piece of mind that duplicates will never be inserted.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Dont repeat username


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway