no actually ur still off

page 1 (form page)
on this page you have your form set up
and on submit you send it to the 2nd page, the processing page

page 2 (processing page)
here u do all the work
first add some code that checks to be sure that the user got to that page by submitting the form, if not throw an error and abort, like such

<!--- make sure form was submitted --->
<cfif  NOT isdefined("form.submit")>
<h2>Sorry there has been an error, please try again</h2>
<p><a href="" back</a></p>
<cfabort>
</cfif>

then what u want to do is trim up all the form fields and set the entries as variables
do this for each form field

<!--- set trim form variables --->
<cfset agent_first_name = #trim(form.first_name)#>
<cfset agent_last_name = #trim(form.last_name)#>

then u can check for duplicate usernames by taking the username variable and running it against a database query, then u do a call to check the recordcount of the query. If it finds a entry it sends it back to the form page with an error message (go to www.dwfaq.com and go to snippetts and then to coldfusion and find my snippet for wrong username and u will see the other part of the code), if the recordcount comes back as 0 then it moves on to the next section

<!--- check for duplicate usernames --->
<cfquery name="qcun" datasource="#dsn#" username="#un#" password="#pw#">
SELECT username
FROM users
WHERE agent_username = <cfqueryparam value="#agent_username#" cfsqltype="cf_sql_varchar">
</cfquery>

<cfif #qcun.recordcount# GTE 1>
<cflocation url="" addtoken="no">
<cfabort>
</cfif>

then u can do the data insert into the database

<!--- do insert now --->
<cfquery name="qinsertUser" datasource="#dsn#" username="#un#" password="#pw#">
INSERT INTO users
(agent_first_name, agent_last_name)
VALUES
(
<cfqueryparam value="#agent_first_name#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_last_name#" cfsqltype="cf_sql_varchar">
)
</CFQUERY>

then send them to the thank you page

<!--- after db insert, send to thank you page --->
<cflocation url="" addtoken="no">

well thats the basic way to do it

then if u want it to log them in, then u must do the login code or send them to a login page and do that there.

2 good tuts on that at www.communitymx.com

actually if u look at my last entry into the cfsilent ? u can see full code

if u want to send me your login page and database fields i will help u out when i get up (its 6am here) guess i better get some sleep
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to