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

*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

Well I got it working, thanks for nothing. :D

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.

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>

*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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.