<cfquery name="check_total_usernames" datasource="my-site">
SELECT *
FROM bodyfun_registry
WHERE userName like '#Form.userName#%'
</cfquery>
----- Original Message -----
From: "Daniel Kessler" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, March 19, 2004 10:52 AM
Subject: unique user query
> I'm doing a registration test. First I test the name and if it
> fails, I try to get the total number of userNames that begin with the
> name and suggest that as a new name (ie daniel87697). Then I test to
> make sure that name is valid. Unfortunately, the second query where
> I get the count doesn't seem to be working. I'm using % in the
> WHERE, which I understand to be a wild-card. My code below.
>
> <!--- check registration name--->
>
> <cfquery name="check_username" datasource="my-site">
> SELECT *
> FROM bodyfun_registry
> WHERE userName = '#Form.userName#'
> </cfquery>
> <cfif check_username.recordcount gt 0>
>
> <!--- get number of people registered with that as the start
> of their name--->
>
> <cfquery name="check_total_usernames" datasource="my-site">
> SELECT *
> FROM bodyfun_registry
> WHERE userName = '#Form.userName#%'
> </cfquery>
>
> <!--- check the new suggested name--->
>
> <cfquery name="check_new_username" datasource="my-site">
> SELECT *
> FROM bodyfun_registry
> WHERE userName =
> '#Form.userName##check_total_usernames.recordcount#'
> </cfquery>
>
> <!--- output--->
> <cfif check_new_username.recordcount gt 0>
> <cfset nameError = "This name is already taken. The name
> must be unique.">
> <cfelse>
> <cfset nameError = "This name is already taken. The name
> must be unique.
> Suggestion:#Form.userName##check_total_usernames.recordcount#">
> </cfif>
>
> <cfset errorState = true>
> </cfif>
>
> I'm sure there's a better way to suggest a name, but this is an added
> feature so I'm doing it as well as I can do quickly.
>
> thanks.
>
> --
> Daniel Kessler
>
> Department of Public and Community Health
> University of Maryland
> Suite 2387 Valley Drive
> College Park, MD 20742-2611
> 301-405-2545 Phone
> www.phi.umd.edu
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

