Avatar of sglee
sglee
 asked on

Coldfusion V9 Form Error

FormEntry ErrorServer Settings Page 1Server Settings Page 2Hi,
I am running Coldfusion v9 (migrated from Coldfusion v7) and running on error on the same cfm page that used to run just fine in CF7 environment.
I found an article where they talk about this type of error and apparently one person in that discussion pointed out that we can turn this feature off.
Here is the link:
https://www.bennadel.com/blog/767-new-coldfusion-error-form-entries-incomplete-or-invalid.htm

However it does not say exactly what feature/function to turn off in CF admin.

Can you help?
ColdFusion Language

Avatar of undefined
Last Comment
sglee

8/22/2022 - Mon
_agx_

I looked around in CF11 but didn't see anything in the Admin that looked relevant.  They did add a new application level setting (requires an Application.cfc)



CF9+ - Application.cfc

this.serverSideFormValidation="false";

Open in new window


http://www.raymondcamden.com/index.cfm/2009/7/12/My-first-ColdFusion-9-scoop--disable-server-side-validation

CF8 - Application.cfc

<cfset this.name = "myApplication">
<cfset url.form = structnew()/>
<cfset structappend(url.form,form)/>
<cfset structclear(form)/>
<cffunction name="onRequestStart">
    <cfset structappend(form,url.form)/>
    <cfset structdelete(url,"form")/>
</cffunction>

Open in new window


http://www.cfinsider.com/index.cfm/2008/9/30/Getting-Around-ColdFusion-Form-Validation


Keep in mind there's also a bug report about the application level setting that was fixed in later versions. If it affects your app, you may want to rename the form fields instead.
https://tracker.adobe.com/#/view/cf-4170204

Server Side Hidden Field Validation Rules
sglee

ASKER
where (folder location) do I create CFC file and how do I reference it?
All my CFM website-related files are located off C:\inetpub\wwwroot. For example, Online Order CFM & HTML files are located in C:\inetpub\wwwroot\OnlineOrder folder.
Coldfusion is installed in C:\ColdFusion9 folder.
I also see C:\inetpub\wwwroot\cfdocs, C:\inetpub\wwwroot\CFIDE, C:\inetpub\wwwroot\aspnet_client folders.
_agx_

All my CFM website-related files are located off C:\inetpub\wwwroot

You can put it there, but all depends on the structure of your apps.  It acts just like an Application.cfm  file, only with more features. You don't need reference it. Like an Application.cfm file, it runs automatically whenever a .cfm/cfml script in that same directory (or subdirectories) is invoked.

Do your websites already use an Application.cfm? If yes, you'll need to convert them.  If you need help, just attach them here and I'd be happy to help.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
sglee

ASKER
I have multiple sub-folders under C:\Webroot. Each sub-folder was created whenever I need to create a new website.
So by putting .CFC file in C:\Webroot, the code in .CFC file will be effective on all existing CFM files in sub-folders in C:\Webroot?
sglee

ASKER
"Do your websites already use an Application.cfm?" --> I see application.cfm file in virtually every sub-folder (which was created for each website).
_agx_

If you mean "C:\inetpub\wwwroot" yes -  unless the existing subfolders already contains an Application.cfm/cfc file.  

When you run a .cfm script, CF searches the current directory for an Application.cfc/cfm file. If it's found, CF stops looking and uses that one. Otherwise, it searches all parent directories until it finds one.  

For example, if you request page /siteB/pageB.cfm OR /siteA/pageB.cfm CF will use {root}/Application.cfc, because the "siteA" and "siteB" subfolders don't have an Application.cfm/cfc file.

C:\inetpub\wwwroot\Application.cfc
C:\inetpub\wwwroot\siteA\pageA.cfm
C:\inetpub\wwwroot\siteA\pageB.cfm
C:\inetpub\wwwroot\siteB\pageA.cfm
C:\inetpub\wwwroot\siteB\pageB.cfm

BUT ... say the "siteB" subfolder already contains an Application.cfm file:

C:\inetpub\wwwroot\Application.cfc
C:\inetpub\wwwroot\siteA\pageA.cfm
C:\inetpub\wwwroot\siteA\pageB.cfm
C:\inetpub\wwwroot\siteB\Application.cfm
C:\inetpub\wwwroot\siteB\pageA.cfm
C:\inetpub\wwwroot\siteB\pageB.cfm

* When you request page /siteB/pageA.cfm, CF will use siteB/Application.cfm - NOT /Application.cfc.
* When you request page /siteA/pageA.cfm, CF will use /Application.cfc - because the "siteA" folder doesn't contain an Application.cfm/cfc file
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
_agx_

Update: Fix broken link

I see application.cfm file in virtually every sub-folder (which was created for each website).

Then you'll either have to

1. Convert the Application.cfm files to Application.cfc and use the new setting
2. Convert theApplication.cfm files and try the CF8 workaround mentioned here https://web.archive.org/web/20111206102804/http://www.cfinsider.com/index.cfm/2008/9/30/Getting-Around-ColdFusion-Form-Validation
3. Rename the form fields
sglee

ASKER
1. I have all my website related files in C:\Webroot folder instead of C:\inetpub\wwwroot. Fyi it has been that way all these years in old Web server and I simply copied all the files to this new server and kept the same folder structure. Is it necessary to move them to C:\inetpub\wwwroot folder?
2. I misspoke about existence of application.cfm files in multiple website folders. Yes application.cfm files are there, but most websites have been migrated to web hosting companies and we only run two websites on this web server locally. When I look at the C:\Webroot\SiteA folder, I do not see application.cfm file. I must have not needed it. Having said that, can I just create a new file "application.cfc" in Notepad and add -this.serverSideFormValidation="false"  - and save the file?
_agx_

A) Can you post the Application.cfm files for the two sites (minus any confidential info)?
B)  "can I just create a new file "application.cfc" in Notepad and add -this.serverSideFormValidation="false""
No, it needs a few more properties minimum - like application "name", enabling session management (if your app uses session variables), etc...  That's why it'd help to see the existing Application.cfm files.
C) Which directory is your web root, ie "/" - C:\inetpub\wwwroot or C:\Webroot\?
Your help has saved me hundreds of hours of internet surfing.
fblack61
sglee

ASKER
A) There was not cfm file in the website that I am having this problem with. However I opened a few others and one of them looks like this:
-----------------------------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE></TITLE>
<META name="description" content="">
<META name="keywords" content="">
<META name="generator" content="CuteHTML">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
<!--Don't forget to add your FREE HitBOX statistics to your web page. To
do so, click on Online Services\HitBox Statistics...-->
<CFAPPLICATION NAME="DSW"
SESSIONMANAGEMENT="Yes"
SESSIONTIMEOUT="#CreateTimeSpan(0, 0, 20, 0)#">
-----------------------------------------------------------------------------------------

Below is another CFM. This one handles login process.
-----------------------------------------------------------------------------------------
<cfapplication name="onlineorder" sessionmanagement="Yes" sessiontimeout="#CreateTimeSpan(0,4,0,0)#" setclientcookies="Yes">
<CFSET APPLICATION.FACE = "verdana,arial,helvetica">
<CFSET APPLICATION.HistoryHeaderBGColor = "435663">
<CFSET APPLICATION.HistoryFieldTitleBGColor = "D7D7D7">
<CFSET APPLICATION.HistoryFieldHeaderColor = "">
<CFSET APPLICATION.HistoryFieldTextBGColor = "">


      <!---Check to see if the session is valid, or its a login attempt--->
      <cfparam name="session.LoggedIn" default="false">  
      <cfif not isdefined("LoginAttempt")>
            <cfif session.LoggedIn is false and listlast(cgi.script_name,"/") neq "login.cfm">
            <cflocation url="login.cfm">
            </cfif>
      </cfif>

      <!--- initialize application variable if it doesn't exist yet --->
      <cfif NOT structKeyExists(Application, "UsersInfo")>
            <cflock timeout="15" scope="Application" type="exclusive">
               <cfif NOT structKeyExists(Application, "UsersInfo")>
                  <cfset Application.UsersInfo = StructNew()>
                </cfif>
            </cflock>
      </cfif>

      <!--- if this is a new user that IS logged in, save the login details --->
      <cflock timeout="15" scope="Application" type="exclusive">
            <cfif NOT StructKeyExists(Application.UsersInfo, COOKIE.CFID)
                  AND structKeyExists(session, "name")>
            <cfset newUser = structNew()>
            <cfset newUser.userTime  = now()>
            <cfset newUser.userName = session.name>
            <cfset Application.UsersInfo[COOKIE.CFID] = newUser>
             </cfif>
      </cflock>

      <!--- remove expired logins --->
      <cflock scope="Application" type="exclusive" timeout="15">
       <cfloop collection="#Application.UsersInfo#" item="userData">
              <cfif  DateDiff("n", Application.UsersInfo[userData].userTime, Now()) GT 10>
                <cfset StructDelete(Application.UsersInfo, userData)>
              </cfif>
          </cfloop>
      </cflock>
</BODY>
</HTML>
-----------------------------------------------------------------------------------------

For this webpage(where I get an error), I don't need "login process" application.cfm either. This page simply takes input on a blank form and stores the data in Access database.
So nothing to move over.
_agx_

So you don't need any of the login sections  OR you don't need the Application.cfm at all?  Reason I ask is the 2nd example also defines some application variables (application.FACE, etc...). Removing them might break other pages if they're used elsewhere in your code.
sglee

ASKER
"also defines some application variables (application.FACE, etc...)."  --> I see. Yes they are not important at all.

I forgot to answer one of your questions:
C) Which directory is your web root, ie "/" - C:\inetpub\wwwroot or C:\Webroot\? --> I created C:\webroot folder manually in my old web server and did the same thing on the new web server that I am working on. I think  C:\inetpub\wwwroot  was created as I installed IIS role in Server Manager.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
_agx_

1. Okay, but what does "/" resolve to?  ie

<cfoutput>The web root is #ExpandPath("/")#</cfoutput>

2.  Is it okay for both sites to share the same settings (session timeout, application name, etc...)?
SOLUTION
_agx_

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
sglee

ASKER
OK. I will try it and let you know if it takes care of the error.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
sglee

ASKER
<cfset this.serverSideFormValidation="true"> ---> should this set to "false"?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
sglee

ASKER
Yes it worked. I changed to "false". Of course you knew that.

<cfcomponent>
      <cfset this.Name = "SANECK International">
      <cfset this.sessionManagement = "yes">
      <cfset this.sessionTimeOut = CreateTimeSpan(0,4,0,0)>
      <cfset this.setClientCookies = "yes">
      <cfset this.serverSideFormValidation="false">
</cfcomponent>

Thanks for your help and I appreciate it.
_agx_

Yep.  I accidentally left it turned on (from testing). Glad I could help.
sglee

ASKER
Thank you AGX.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.