| | |
Check new UserID - if taken or not
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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
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
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.
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.
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.
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
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>
<!--- 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
![]() |
Similar Threads
- USB Ports not recognizing periferals (USB Devices and other Peripherals)
- Will someone please check my HijackThis log? (Viruses, Spyware and other Nasties)
- Assistance (ColdFusion)
- Anyone Could Help Me Out?? Please.. (Shell Scripting)
- IE6 - dialogue boxes , check boxes and radio buttons work very slowly after hijacking (Viruses, Spyware and other Nasties)
- Ureaka!! I found it! Please check this log (Web Browsers)
- flash check it out (Geeks' Lounge)
Other Threads in the ColdFusion Forum
- Previous Thread: Show Numbers of Deleted entries from database
- Next Thread: creating a new folder via code
| Thread Tools | Search this Thread |





