943,774 Members | Top Members by Rank

Ad:
  • ColdFusion Discussion Thread
  • Marked Solved
  • Views: 5447
  • ColdFusion RSS
Feb 27th, 2006
0

Check new UserID - if taken or not

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
Walyer is offline Offline
26 posts
since Apr 2005
Feb 28th, 2006
0

Re: Check new UserID - if taken or not

*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
Reputation Points: 10
Solved Threads: 1
Light Poster
Walyer is offline Offline
26 posts
since Apr 2005
Mar 8th, 2006
0

Re: Check new UserID - if taken or not

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.
Reputation Points: 10
Solved Threads: 1
Light Poster
Walyer is offline Offline
26 posts
since Apr 2005
Mar 25th, 2006
0

Re: Check new UserID - if taken or not

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>

Quote 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
paulbaylis is offline Offline
2 posts
since Mar 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ColdFusion Forum Timeline: Show Numbers of Deleted entries from database
Next Thread in ColdFusion Forum Timeline: creating a new folder via code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC