ok, say i have this page (see code below)
what would be all the ways to optimize it?
sorry the formatting got jacked when i pasted

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

<!--- set trim form variables --->
<cfset agent_first_name = #trim(form.first_name)#>
<cfset agent_last_name = #trim(form.last_name)#>
<cfset agent_company = #trim(form.company)#>
<cfset agent_email = #trim(form.email)#>
<cfset agent_username = #trim(form.username)#>
<cfset agent_password = #trim(form.password)#>
<cfset agent_home_phone = #trim(form.home_phone)#>
<cfset agent_work_phone = #trim(form.work_phone)#>
<cfset agent_toll_free = #trim(form.toll_free)#>
<cfset agent_cell_phone = #trim(form.cell_phone)#>
<cfset agent_fax = #trim(form.fax)#>
<cfset agent_url = #trim(form.web)#>
<cfset agent_address1 = #trim(form.address)#>
<cfset agent_address2 = #trim(form.address_more)#>
<cfset agent_city = #trim(form.city)#>
<cfset agent_state = #form.state#>
<cfset agent_zip = #trim(form.zip)#>
<cfset agent_country = #form.country#>
<cfset agent_IP = #form.ip#>
<cfset startdate = #CreateODBCDate(Now())#>
<cfset agent_bio = "na">
<cfset agent_region = "na">
<cfset agent_province = "na">

<!--- secure variables --->
<cfset agent_first_name = #HTMLEditFormat(agent_first_name)#>
<cfset agent_last_name = #HTMLEditFormat(agent_last_name)#>
<cfset agent_company = #HTMLEditFormat(agent_company)#>
<cfset agent_username = #HTMLEditFormat(agent_username)#>
<cfset agent_password = #HTMLEditFormat(agent_password)#>
<cfset agent_url = #HTMLEditFormat(agent_url)#>
<cfset agent_city = #HTMLEditFormat(agent_city)#>
<cfset agent_address1 = #HTMLEditFormat(agent_address1)#>
<cfset agent_address2 = #HTMLEditFormat(agent_address2)#>

<!--- check for duplicate usernames --->
<cfquery name="qcun" datasource="#dsn#" username="#un#" password="#pw#">
SELECT agent_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>

<cftry>
<cftransaction>
<!--- do insert now --->
<cfquery name="qinsertUser" datasource="#dsn#" username="#un#" password="#pw#">
INSERT INTO users
(agent_first_name, agent_last_name, agent_company, agent_email, agent_username,
agent_password, agent_home_phone, agent_work_phone, agent_toll_free, agent_cell_phone,
agent_fax, agent_url, agent_address1, agent_address2, agent_city, agent_state,
agent_zip, agent_country, agent_IP, startdate, agent_bio, agent_region, agent_province)
VALUES
(
<cfqueryparam value="#agent_first_name#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_last_name#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_company#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_email#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_username#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_password#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_home_phone#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_work_phone#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_toll_free#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_cell_phone#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_fax#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_url#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_address1#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_address2#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_city#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_state#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_zip#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_country#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_IP#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#startdate#" cfsqltype="cf_sql_date">
,
<cfqueryparam value="#agent_bio#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_region#" cfsqltype="cf_sql_varchar">
,
<cfqueryparam value="#agent_province#" cfsqltype="cf_sql_varchar">
)
</CFQUERY>
</cftransaction>

<!--- catch any db errors --->
<cfcatch type="database">
<div align="center">
<font face="Times New Roman, Times, serif">
<hr />
<h2>Sorry there has been an error with the database, please try again</h2>
<br />
<a href="" back</a>
<hr />
</font>
</div>

<font face="Times New Roman, Times, serif">
There error information is as follows:
<p>
<cfoutput>
<strong>SQL STATE</strong>: #cfcatch.SQLState#<br />
<strong>NATIVE ERROR CODE</strong>: #cfcatch.NativeErrorCode#<br />
<strong>type</strong>: #cfcatch.Type#<br />
<strong>message</strong>: #cfcatch.Message#<br />
<strong>TAG CONTENT</strong>:
<ul>
<cfif arrayLen(cfcatch.tagcontext)>
<cfloop index="a" from="1" to="#arrayLen(cfcatch.tagcontext)#">
<cfset CURRENT_TAG_STACK = #cfcatch.tagcontext[A]#>
<li><strong>#CURRENT_TAG_STACK["ID"]#</strong>
(#CURRENT_TAG_STACK["LINE"]#, #CURRENT_TAG_STACK["COLUMN"]#)
#CURRENT_TAG_STACK["template"]#
</li>
</cfloop>
<cfelse>
The tag stack is empty (it might have been disabled in the Coldfusion Administrator)
<br />
<br />
</cfif>
</ul>
<strong>DETAILS</strong>
<form>
<textarea cols="50" rows="1" name="detail">#HTMLeditFormat(cfcatch.Detail)#</textarea>
</form>
</cfoutput>
</font>
</cfcatch>
</cftry>

<!--- after db insert, send to thank you page --->
<cflocation url="" addtoken="no">
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to