Check new UserID - if taken or not

Thread Solved

Join Date: Apr 2005
Posts: 26
Reputation: Walyer is an unknown quantity at this point 
Solved Threads: 1
Walyer's Avatar
Walyer Walyer is offline Offline
Light Poster

Check new UserID - if taken or not

 
0
  #1
Feb 27th, 2006
Hey all,

I’ve created a register form that includes some Dreamweaver generated code and code of my own. What I did was within the main query that handles the insert of the userID I added another query within the <cfif> to see if the userID already exists. The problem is that when I test the form it goes no where, just keeps thinking.

The dark orange is where i believe I have the problem.

Here is the my query code;

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="FORM.UserID" default="1">
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "register">
<cfquery datasource="walyerMembers">
INSERT INTO tblWalyerMembers (UserID, Password, Date, Email)
VALUES (
<cfif IsDefined("FORM.userid") AND #FORM.userid# NEQ "">
<cfquery name="Recordset1" datasource="walyerMembers">
SELECT UserID
FROM tblWalyerMembers
WHERE UserID = '#FORM.UserID#'
<cfoutput>
<cfinclude template="register.cfm" />
<div align="center" class="style3">*Your User Name is already taken by another User.*</div>
</cfoutput>
</cfquery>
<cfelse>
'#FORM.userid#'
</cfif>

,
<cfif IsDefined("FORM.password") AND #FORM.password# NEQ "">
'#FORM.password#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.email") AND #FORM.email# NEQ "">
'#FORM.email#'
<cfelse>
NULL
</cfif>
)</cfquery>
<cflocation url="registerComplete.cfm">
</cfif>

Any ideas will be great.

Take care,

Walyer

Walyer's Playpen
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 26
Reputation: Walyer is an unknown quantity at this point 
Solved Threads: 1
Walyer's Avatar
Walyer Walyer is offline Offline
Light Poster

Re: Check new UserID - if taken or not

 
0
  #2
Feb 28th, 2006
*Update*

Now I've run into another problem. I changed the Code from above (dark red) by adding a <cfloop query"">. Now my problem (dark orange) is at the next of my INSERT queryand I get this error message "Error Executing Database Query". I'm still new to ColdFusion and the debugging so any ideas would be great.

code;

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="FORM.UserID" default="1">

<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "register">
<cfquery datasource="walyerMembers">
INSERT INTO tblWalyerMembers (UserID, Password, Email)
VALUES (

<cfif IsDefined("FORM.userid") AND #FORM.userid# EQ "">
<cfoutput>
<cfinclude template="register.cfm" />
<div align="center" class="style3">*Your must enter a User Name.*</div>
</cfoutput>


<cfelse>

<cfquery name="Recordset1" datasource="walyerMembers">
SELECT UserID
FROM tblWalyerMembers
WHERE UserID = '%#FORM.UserID#%'
</cfquery>
<cfloop query="Recordset1">
<cfif UserID EQ '#FORM.userID#'>
<cfoutput>
<cfinclude template="register.cfm" />
<div align="center" class="style3">*Your User Name is already taken by another User.*</div>
</cfoutput>


<cfelse>
'#FORM.userID#'
</cfif>
</cfloop>
</cfif>
,

<cfif IsDefined("FORM.password") AND #FORM.password# NEQ "">
'#FORM.password#'
<cfelse>
NULL
</cfif>
,

<cfif IsDefined("FORM.email") AND #FORM.email# NEQ "">
'#FORM.email#'
<cfelse>
NULL
</cfif>

)</cfquery>
<cflocation url="registerComplete.cfm">
</cfif>

Thank you to anyone that can help me,

Walyer

Walyer's Playpen
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 26
Reputation: Walyer is an unknown quantity at this point 
Solved Threads: 1
Walyer's Avatar
Walyer Walyer is offline Offline
Light Poster

Re: Check new UserID - if taken or not

 
0
  #3
Mar 8th, 2006
Well I got it working, thanks for nothing.

I don't get it, I would think that someone could see what I did wrong or maybe it was too "advanced" for the users that post on this forum.

Knowledge = Power and i truly believe that knowledge should be passed on no matter how simple the question may seem. We all start off knowing nothing and we build from that.

If anyone would like to know how I did it just post.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 2
Reputation: paulbaylis is an unknown quantity at this point 
Solved Threads: 0
paulbaylis paulbaylis is offline Offline
Newbie Poster

Re: Check new UserID - if taken or not

 
0
  #4
Mar 25th, 2006
That seems pretty complicated. Here's a real simple one I use:

<!--- Query table for entered username --->
<cfquery name="GetUser" datasource="1234">
SELECT Username FROM Table WHERE Username = '#Form.Username#'
</cfquery>

<!--- Is the username already taken --->
<cfif GetUser.RecordCount GT 0>
<b>Ooops, the username has already been selected by another user. Please enter a new username</b><br><br>
<input type="button" onClick="history.go(-1)" value="Back">
<cfabort>
</cfif>

Originally Posted by Walyer
*Update*

Now I've run into another problem. I changed the Code from above (dark red) by adding a <cfloop query"">. Now my problem (dark orange) is at the next of my INSERT queryand I get this error message "Error Executing Database Query". I'm still new to ColdFusion and the debugging so any ideas would be great.

code;

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="FORM.UserID" default="1">

<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "register">
<cfquery datasource="walyerMembers">
INSERT INTO tblWalyerMembers (UserID, Password, Email)
VALUES (

<cfif IsDefined("FORM.userid") AND #FORM.userid# EQ "">
<cfoutput>
<cfinclude template="register.cfm" />
<div align="center" class="style3">*Your must enter a User Name.*</div>
</cfoutput>


<cfelse>

<cfquery name="Recordset1" datasource="walyerMembers">
SELECT UserID
FROM tblWalyerMembers
WHERE UserID = '%#FORM.UserID#%'
</cfquery>
<cfloop query="Recordset1">
<cfif UserID EQ '#FORM.userID#'>
<cfoutput>
<cfinclude template="register.cfm" />
<div align="center" class="style3">*Your User Name is already taken by another User.*</div>
</cfoutput>


<cfelse>
'#FORM.userID#'
</cfif>
</cfloop>
</cfif>
,

<cfif IsDefined("FORM.password") AND #FORM.password# NEQ "">
'#FORM.password#'
<cfelse>
NULL
</cfif>
,

<cfif IsDefined("FORM.email") AND #FORM.email# NEQ "">
'#FORM.email#'
<cfelse>
NULL
</cfif>

)</cfquery>
<cflocation url="registerComplete.cfm">
</cfif>

Thank you to anyone that can help me,

Walyer

Walyer's Playpen
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ColdFusion Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC