Without running it to check, here's what I think you need to eliminate
a lot of the white space.

Incidentally i notice you're using the XHTML style tags (<br />) which
is good, but you also have a font tag.  That's deprecated and you
shouldn't use it.  Instead use a style sheet and put your styling in
there.  It's far more powerful, faster, smaller, and easier to
maintain.

Instead of:
  <div align="center">     
     <font face="Times New Roman, Times, serif">

put this:
<div class="error">

And in your style sheet, have something like the following:

.error {
font-family:"Times New Roman", Times, serif;
text-align: center;
}

That way, whenever you use <div class="error"> the resulting style
will be defined by the single paragraph in the style sheet.  One
change there, and all instances of the 'error' class will change
throughout the whole site.

Anyway, your question was about white space control.  Putting the   
CFsetting tag at the top and bottom of the page ensures that anywhere
you might use this page will not affect other pages it might be called
as an include.  If you didnt turn the cfsetting off at the bottom of
the page, and then included it in another page, the enableoutputonly
would still be turned on through that next page.  That might or might
not be what you want.  It's a better way to have your pages
self-contained at least as far as whitespace control is concerned.

HTH

<cfsetting enablecfoutputonly="Yes">
<!--- make sure form was submitted --->   
  <cfif  NOT isdefined("form.jam")>
  <cfoutput>
  <h2>Sorry there has been an error, please try again</h2>
<p><a href=""> Go back
</a></p>
</cfoutput>
   <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">
<cfoutput>
  <div class="error">     
   
<hr/><h2>Sorry there has been an error with the database, please try
again</h2><br/><a href=""> Go back
</a>
<hr/></font>

      There error information is as follows:
<p>
<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>

</div>
</cfoutput>
</cfcatch></cftry><!--- after db insert, send to thank you page --->
    <cflocation url="" addtoken="no">
<cfsetting enablecfoutputonly="no">

Cheers
Mike Kear
Windsor, NSW, Australia
AFP Webworks
http://afpwebworks.com
.com,.net,.org domains from AUD$20/Year

----- Original Message -----
From: dave <[EMAIL PROTECTED]>
Date: Wed, 29 Sep 2004 06:03:31 -0400
Subject: Re: cfsilent tag
To: CF-Talk <[EMAIL PROTECTED]>

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

[snip]
--
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to