Copy link to clipboard
Copied
I have inherited maintenance of a website created in Cold Fusion back in 2007. While I can easily make the typical content edits in Dreamweaver, there has recently been a problem with on of the form pages and I know nothing about coding Cold Fusion.
When completing and submitting the form this error message is generated:
Variable G is undefined. | |||||||||
The error occurred in <generated>: line 1 Called from C:/inetpub/vhosts/designerbuilders.com/httpdocs/cfc/clients.cfc: line 121 Called from C:/inetpub/vhosts/designerbuilders.com/httpdocs/register.cfm: line 246 | |||||||||
-1 : Unable to display error's location in a CFML template. | |||||||||
Resources:
| |||||||||
|
Stack Trace |
at Statement8591.evaluate(<generated>:1) at cfclients2ecfc294135730$funcLOADVARS.runFunction(C:/inetpub/vhosts/designerbuilders.com/httpdocs/cfc/clients.cfc:121) at cfregister2ecfm309030383.runPage(C:/inetpub/vhosts/designerbuilders.com/httpdocs/register.cfm:246) coldfusion.runtime.UndefinedVariableException: Variable G is undefined. at coldfusion.runtime.CfJspPage._get(CfJspPage.java:314) at coldfusion.runtime.CfJspPage._get(CfJspPage.java:298) at coldfusion.runtime.CfJspPage._autoscalarize(CfJspPage.java:1532) at coldfusion.runtime.CfJspPage._autoscalarize(CfJspPage.java:1494) at Statement8591.evaluate(<generated>:1) at coldfusion.compiler.ExprClassLoader.evaluate(ExprClassLoader.java:149) at coldfusion.runtime.CFPage.Evaluate(CFPage.java:2320) at cfclients2ecfc294135730$funcLOADVARS.runFunction(C:\inetpub\vhosts\designerbuilders.com\httpdocs\cfc\clients.cfc:121) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:231) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:643) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:432) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:402) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2483) at cfregister2ecfm309030383.runPage(C:\inetpub\vhosts\designerbuilders.com\httpdocs\register.cfm:246) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246) at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:736) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:572) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:45) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:466) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:42) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:142) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:151) at coldfusion.CfmServlet.service(CfmServlet.java:219) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:134) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doNext(FusionReactorRequestHandler.java:802) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doHttpServletRequest(FusionReactorRequestHandler.java:339) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doFusionRequest(FusionReactorRequestHandler.java:215) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.handle(FusionReactorRequestHandler.java:839) at com.intergral.fusionreactor.j2ee.filter.FusionReactorCoreFilter.doFilter(FusionReactorCoreFilter.java:36) at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:71) at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intergral.fusionreactor.agent.filter.FusionReactorStaticFilter.doFilter(FusionReactorStaticFilter.java:53) at com.intergral.fusionreactor.agent.pointcuts.NewFilterChainPointCut$1.invoke(NewFilterChainPointCut.java:41) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:450) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:197) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) |
I have checked the lines referenced but don't know what the error fix would be. Here are the line codes:
Called from C:/inetpub/vhosts/designerbuilders.com/httpdocs/cfc/clients.cfc: line 121
116 <cfif isdefined('arguments.stValues')>
117 <cfif arraylen(structkeyarray(arguments.stValues) ) gt 0>
118 <cfset fieldarray = structkeyarray(arguments.stValues)>
119 <cfloop from='1' to='#arraylen(fieldarray)#' index='i'>
120 <cfif findnocase('fieldnames',fieldarray) eq 0 and findnocase('submit',fieldarray) eq 0>
121 <cfset "arguments.obj.#fieldarray#" = evaluate(fieldarray) >
122 </cfif>
123 </cfloop>
124 </cfif>
Called from C:/inetpub/vhosts/designerbuilders.com/httpdocs/register.cfm: line 246
246 <cfset xclient = clientbean.loadvars(form)>
Any help would be appreciated.
Copy link to clipboard
Copied
I cant' tell exactly what it is doing or what the expected obj result should look like but my guess is that this can be greatly simplified. I'm guessing it is simply copying the FORM scope into the obj object but I would really need more to go on - maybe the entire loadvars function.
This appears to either be "learning code" where the code was written by someone learning CF at the time or specific to an older version of CF. I would guess the former. (I'm not meaning to disparage, I have code like this still running around)
You may be able to replace all the shown code above lines 117-124 with something as simple as structCopy(arguments.obj,arguments.stValues).
Copy link to clipboard
Copied
Unfortunately, I don't the whys or hows of the original set up or the designers experience. And while your answer sounds great, I am hesitant to try it since I know nothing about Cold Fusion coding.
Would it help to be more certain if you could fully the problem? I have provided ALL of the .cfc code and a link to the form for more detailed examination.
This is a link to the website form page in quesiton: http://www.designerbuilders.com/register.cfm
This is the full clients.cfc file:
<cfcomponent output="false" alias="cfc.clients">
<!---
These are properties that are exposed by this CFC object.
These property definitions are used when calling this CFC as a web services,
passed back to a flash movie, or when generating documentation
NOTE: these cfproperty tags do not set any default property values.
--->
<cfproperty name="cid" type="numeric" default="0">
<cfproperty name="firstname" type="string" default="">
<cfproperty name="lastname" type="string" default="">
<cfproperty name="address" type="string" default="">
<cfproperty name="city" type="string" default="">
<cfproperty name="st" type="string" default="">
<cfproperty name="zip" type="string" default="">
<cfproperty name="phone1" type="string" default="">
<cfproperty name="phone2" type="string" default="">
<cfproperty name="cname" type="string" default="">
<cfproperty name="datecreated" type="date" default="">
<cfproperty name="lastlogin" type="date" default="">
<cfproperty name="news" type="numeric" default="0">
<cfproperty name="homesize" type="string" default="">
<cfproperty name="buildtime" type="string" default="">
<cfproperty name="subdivid" type="numeric" default="0">
<cfproperty name="ownlot" type="numeric" default="0">
<cfproperty name="lotnum" type="string" default="">
<cfproperty name="cragree" type="numeric" default="0">
<cfproperty name="curclient" type="numeric" default="0">
<cfproperty name="clientdir" type="string" default="">
<cfproperty name="active" type="numeric" default="0">
<cfproperty name="email" type="string" default="">
<cfproperty name="pw" type="string" default="">
<cfproperty name="oldemail" type="string" default="">
<cfproperty name="oldpw" type="string" default="">
<cfproperty name="confirmed" type="numeric" default="0">
<cfproperty name="confirmcode" type="string" default="">
<cfproperty name="confirmdate" type="date" default="">
<cfproperty name="rid" type="numeric" default="0">
<cfproperty name="privpolicy" type="numeric" default="0">
<cfproperty name="contractdate" type="date" default="">
<cfproperty name="jobname" type="string" default="">
<cfproperty name="joblocation" type="string" default="">
<cfproperty name="jobnum" type="string" default="">
<cfproperty name="password" type="string" default="">
<cfproperty name="passwordconfirm" type="string" default="">
<cfproperty name="followup" type="numeric" default="0">
<cfproperty name="followupdate" type="date" default="">
<cfproperty name="followupby" type="string" default="">
<cfproperty name="emailfollowup" type="numeric" default="0">
<cfproperty name="emailfollowupdate" type="date" default="">
<cfproperty name="phonefollowup" type="numeric" default="0">
<cfproperty name="phonefollowupdate" type="date" default="">
<cfproperty name="clientnotes" type="string" default="">
<cfscript>
//Initialize the CFC with the default properties values.
this.cid = 0;
this.firstname = "";
this.lastname = "";
this.address = "";
this.city = "";
this.st = "";
this.zip = "";
this.phone1 = "";
this.phone2 = "";
this.cname = "";
this.datecreated = "";
this.lastlogin = "";
this.news = 0;
this.homesize = "";
this.buildtime = "";
this.subdivid = 0;
this.ownlot = 0;
this.lotnum = "";
this.cragree = 0;
this.curclient = 0;
this.clientdir = "";
this.active = 0;
this.email = "";
this.pw = "";
this.oldemail = "";
this.oldpw = "";
this.confirmed = 0;
this.confirmcode = "";
this.confirmdate = "";
this.rid = 0;
this.privpolicy = 0;
this.contractdate = "";
this.jobname = "";
this.joblocation = "";
this.jobnum = "";
this.password = "";
this.passwordconfirm = "";
this.followupdate = '';
this.followup = 0;
this.followupby = '';
this.emailfollowupdate = '';
this.emailfollowup = 0;
this.phonefollowupdate = '';
this.phonefollowup = 0;
this.clientnotes='';
</cfscript>
<cffunction name="init" output="false" returntype="clients">
<cfreturn this>
</cffunction>
<cffunction name="loadvars" output="false" returntype="clients">
<cfargument name="stValues" required="no" type="struct">
<cfargument name="obj" required="no" type='cfc.clients'>
<cfif not isdefined('arguments.obj')>
<cfset arguments.obj = this.init()>
</cfif>
<cfset var fieldarray = arraynew(1)> <!--- to hold form structure fieldnames --->
<cfif isdefined('arguments.stValues')>
<cfif arraylen(structkeyarray(arguments.stValues) ) gt 0>
<cfset fieldarray = structkeyarray(arguments.stValues)>
<cfloop from='1' to='#arraylen(fieldarray)#' index='i'>
<cfif findnocase('fieldnames',fieldarray) eq 0 and findnocase('submit',fieldarray) eq 0>
<cfset "arguments.obj.#fieldarray#" = evaluate(fieldarray) >
</cfif>
</cfloop>
</cfif>
</cfif>
<cfreturn arguments.obj>
</cffunction>
<cffunction name="getCid" output="false" access="public" returntype="any">
<cfreturn this.Cid>
</cffunction>
<cffunction name="setCid" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Cid = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getFirstname" output="false" access="public" returntype="any">
<cfreturn this.Firstname>
</cffunction>
<cffunction name="setFirstname" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Firstname = arguments.val>
</cffunction>
<cffunction name="getLastname" output="false" access="public" returntype="any">
<cfreturn this.Lastname>
</cffunction>
<cffunction name="setLastname" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Lastname = arguments.val>
</cffunction>
<cffunction name="getaddress" output="false" access="public" returntype="any">
<cfreturn this.address>
</cffunction>
<cffunction name="setaddress" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.address = arguments.val>
</cffunction>
<cffunction name="getCity" output="false" access="public" returntype="any">
<cfreturn this.City>
</cffunction>
<cffunction name="setCity" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.City = arguments.val>
</cffunction>
<cffunction name="getSt" output="false" access="public" returntype="any">
<cfreturn this.St>
</cffunction>
<cffunction name="setSt" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.St = arguments.val>
</cffunction>
<cffunction name="getZip" output="false" access="public" returntype="any">
<cfreturn this.Zip>
</cffunction>
<cffunction name="setZip" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Zip = arguments.val>
</cffunction>
<cffunction name="getPhone1" output="false" access="public" returntype="any">
<cfreturn this.Phone1>
</cffunction>
<cffunction name="setPhone1" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Phone1 = arguments.val>
</cffunction>
<cffunction name="getPhone2" output="false" access="public" returntype="any">
<cfreturn this.Phone2>
</cffunction>
<cffunction name="setPhone2" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Phone2 = arguments.val>
</cffunction>
<cffunction name="getCname" output="false" access="public" returntype="any">
<cfreturn this.Cname>
</cffunction>
<cffunction name="setCname" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Cname = arguments.val>
</cffunction>
<cffunction name="getDatecreated" output="false" access="public" returntype="any">
<cfreturn this.Datecreated>
</cffunction>
<cffunction name="setDatecreated" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsDate(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Datecreated = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid date"/>
</cfif>
</cffunction>
<cffunction name="getLastlogin" output="false" access="public" returntype="any">
<cfreturn this.Lastlogin>
</cffunction>
<cffunction name="setLastlogin" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsDate(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Lastlogin = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid date"/>
</cfif>
</cffunction>
<cffunction name="getNews" output="false" access="public" returntype="any">
<cfreturn this.News>
</cffunction>
<cffunction name="setNews" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.News = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getHomesize" output="false" access="public" returntype="any">
<cfreturn this.Homesize>
</cffunction>
<cffunction name="setHomesize" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Homesize = arguments.val>
</cffunction>
<cffunction name="getBuildtime" output="false" access="public" returntype="any">
<cfreturn this.Buildtime>
</cffunction>
<cffunction name="setBuildtime" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Buildtime = arguments.val>
</cffunction>
<cffunction name="getSubdivid" output="false" access="public" returntype="any">
<cfreturn this.Subdivid>
</cffunction>
<cffunction name="setSubdivid" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Subdivid = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getOwnlot" output="false" access="public" returntype="any">
<cfreturn this.Ownlot>
</cffunction>
<cffunction name="setOwnlot" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Ownlot = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getLotnum" output="false" access="public" returntype="any">
<cfreturn this.Lotnum>
</cffunction>
<cffunction name="setLotnum" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Lotnum = arguments.val>
</cffunction>
<cffunction name="getCragree" output="false" access="public" returntype="any">
<cfreturn this.Cragree>
</cffunction>
<cffunction name="setCragree" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Cragree = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getCurclient" output="false" access="public" returntype="any">
<cfreturn this.Curclient>
</cffunction>
<cffunction name="setCurclient" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Curclient = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getClientdir" output="false" access="public" returntype="any">
<cfreturn this.Clientdir>
</cffunction>
<cffunction name="setClientdir" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Clientdir = arguments.val>
</cffunction>
<cffunction name="getActive" output="false" access="public" returntype="any">
<cfreturn this.Active>
</cffunction>
<cffunction name="setActive" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Active = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getEmail" output="false" access="public" returntype="any">
<cfreturn this.Email>
</cffunction>
<cffunction name="setEmail" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Email = arguments.val>
</cffunction>
<cffunction name="getPw" output="false" access="public" returntype="any">
<cfreturn this.Pw>
</cffunction>
<cffunction name="setPw" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Pw = arguments.val>
</cffunction>
<cffunction name="getoldEmail" output="false" access="public" returntype="any">
<cfreturn this.oldEmail>
</cffunction>
<cffunction name="setoldEmail" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.oldEmail = arguments.val>
</cffunction>
<cffunction name="getoldPw" output="false" access="public" returntype="any">
<cfreturn this.oldPw>
</cffunction>
<cffunction name="setoldPw" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.oldPw = arguments.val>
</cffunction>
<cffunction name="getConfirmed" output="false" access="public" returntype="any">
<cfreturn this.Confirmed>
</cffunction>
<cffunction name="setConfirmed" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Confirmed = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getConfirmcode" output="false" access="public" returntype="any">
<cfreturn this.Confirmcode>
</cffunction>
<cffunction name="setConfirmcode" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Confirmcode = arguments.val>
</cffunction>
<cffunction name="getConfirmdate" output="false" access="public" returntype="any">
<cfreturn this.Confirmdate>
</cffunction>
<cffunction name="setConfirmdate" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsDate(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Confirmdate = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid date"/>
</cfif>
</cffunction>
<cffunction name="getRid" output="false" access="public" returntype="any">
<cfreturn this.Rid>
</cffunction>
<cffunction name="setRid" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Rid = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getPrivpolicy" output="false" access="public" returntype="any">
<cfreturn this.Privpolicy>
</cffunction>
<cffunction name="setPrivpolicy" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Privpolicy = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getContractdate" output="false" access="public" returntype="any">
<cfreturn this.Contractdate>
</cffunction>
<cffunction name="setContractdate" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsDate(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Contractdate = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid date"/>
</cfif>
</cffunction>
<cffunction name="getJobname" output="false" access="public" returntype="any">
<cfreturn this.Jobname>
</cffunction>
<cffunction name="setJobname" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Jobname = arguments.val>
</cffunction>
<cffunction name="getJoblocation" output="false" access="public" returntype="any">
<cfreturn this.Joblocation>
</cffunction>
<cffunction name="setJoblocation" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Joblocation = arguments.val>
</cffunction>
<cffunction name="getJobnum" output="false" access="public" returntype="any">
<cfreturn this.Jobnum>
</cffunction>
<cffunction name="setJobnum" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Jobnum = arguments.val>
</cffunction>
<cffunction name="getpassword" output="false" access="public" returntype="any">
<cfreturn this.password>
</cffunction>
<cffunction name="setpassword" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.password = arguments.val>
</cffunction>
<cffunction name="getpasswordconfirm" output="false" access="public" returntype="any">
<cfreturn this.passwordconfirm>
</cffunction>
<cffunction name="setpasswordconfirm" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.passwordconfirm = arguments.val>
</cffunction>
<cffunction name="getFollowup" output="false" access="public" returntype="any">
<cfreturn this.Followup>
</cffunction>
<cffunction name="setFollowup" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.Followup = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getFollowupDate" output="false" access="public" returntype="any">
<cfreturn this.FollowupDate>
</cffunction>
<cffunction name="setFollowupDate" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsDate(arguments.val)) OR (arguments.val EQ "")>
<cfset this.FollowupDate = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid date"/>
</cfif>
</cffunction>
<cffunction name="getfollowupby" output="false" access="public" returntype="any">
<cfreturn this.followupby>
</cffunction>
<cffunction name="setfollowupby" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.followupby = arguments.val>
</cffunction>
<cffunction name="getemailfollowup" output="false" access="public" returntype="any">
<cfreturn this.emailfollowup>
</cffunction>
<cffunction name="setemailfollowup" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.emailfollowup = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getemailfollowupDate" output="false" access="public" returntype="any">
<cfreturn this.emailfollowupDate>
</cffunction>
<cffunction name="setemailfollowupDate" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsDate(arguments.val)) OR (arguments.val EQ "")>
<cfset this.emailfollowupDate = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid date"/>
</cfif>
</cffunction>
<cffunction name="getphonefollowup" output="false" access="public" returntype="any">
<cfreturn this.phonefollowup>
</cffunction>
<cffunction name="setphonefollowup" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset this.phonefollowup = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid numeric"/>
</cfif>
</cffunction>
<cffunction name="getphonefollowupDate" output="false" access="public" returntype="any">
<cfreturn this.phonefollowupDate>
</cffunction>
<cffunction name="setphonefollowupDate" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfif (IsDate(arguments.val)) OR (arguments.val EQ "")>
<cfset this.phonefollowupDate = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid date"/>
</cfif>
</cffunction>
<cffunction name="getClientnotes" output="false" access="public" returntype="any">
<cfreturn this.Clientnotes>
</cffunction>
<cffunction name="setClientnotes" output="false" access="public" returntype="void">
<cfargument name="val" required="true">
<cfset this.Clientnotes = arguments.val>
</cffunction>
/*---------------------------------------------------*/
<cffunction name="validate" output="no" access="remote" returntype="boolean">
<cfargument name="obj" type="struct">
<cfargument name="gethome" required="no" default="0">
<cfset var ok = 1>
<!--- check for empty fields --->
<cfif arguments.obj.getfirstname() eq 0 or arguments.obj.getfirstname() eq ''>
<cfset arrayappend(session.msg.e, '-- You have not provided a visitor first name')>
<cfset ok=0>
</cfif>
<cfif arguments.obj.getlastname() eq 0 or arguments.obj.getlastname() eq ''>
<cfset arrayappend(session.msg.e, '-- You have not provided a visitor last name')>
<cfset ok=0>
</cfif>
<cfif arguments.obj.getemail() eq 0 or arguments.obj.getemail() eq ''>
<cfset arrayappend(session.msg.e, '-- You have not provided a visitor email')>
<cfset ok=0>
</cfif>
<cfif not application.udf.isemail( arguments.obj.getemail() )>
<cfset arrayappend(session.msg.e, '-- You have not entered a valid email')>
<cfset ok=0>
</cfif>
<!--- <cfif not isdefined('form.privpolicy') >
<cfset arrayappend(session.msg.e, "-- Please read and accept the #application.builder# Privacy Policy. ")>
<cfset ok=0>
</cfif>--->
<!--- check for valid passwords --->
<cfif arguments.obj.getcid() eq 0> <!--- new visitor --->
<cfif arguments.obj.getpassword() eq '' or arguments.obj.getpasswordconfirm() eq ''>
<cfset arrayappend(session.msg.e, "-- You must enter both a password, and then confirm it by entering again.")>
</cfif>
</cfif>
<cfif arguments.obj.getpassword() neq '' and arguments.obj.getpasswordconfirm() neq ''>
<cfif arguments.obj.getpassword() neq arguments.obj.getpasswordconfirm()>
<cfset arrayappend(session.msg.e, "-- Your password and password confirmation must match!")>
<cfelse>
<cfset arguments.obj.setpw( arguments.obj.getpassword() )>
</cfif>
</cfif>
<!--- check for valid emails --->
<!--- check for duplicate emails --->
<cfif not arguments.gethome>
<cfset checkemail = createobject('component', 'cfc.clientsgateway').getbyemail(email: arguments.obj.email)>
<cfif isdefined('checkemail.cid')>
<cfif (arguments.obj.getcid() eq 0 and checkemail.getcid() is not '' ) or
(arguments.obj.getcid() neq 0 and checkemail.getcid() neq '' and checkemail.getcid() neq arguments.obj.getcid() ) > <!--- another user has this username --->
<cfset arguments.obj.setemail( arguments.obj.getoldemail())>
<cfset arrayappend(session.msg.e, "Your Email address is already in use by another visitor or Client, <br>Please Choose a different email address<br/><br><b>If you have registered previously and forgotten your password</b>, <br><a href='getpassword.cfm'>Click Here to Have Your Password Sent to You </a>")>
<cfset ok=0>
</cfif>
</cfif>
</cfif>
<cfreturn ok>
</cffunction>
</cfcomponent>
Copy link to clipboard
Copied
I'm actually surprised that the loadvars function works at all. The evaluate call is not scoped and I believe the intent was to copy from the arguments.stValues scope. Because it is not scoped, it is only working because FORM is one of the default scopes that is walked through and I believe it is normally (and accidentally) pulling from the FORM scope and ignoring the stValues setting even though it is using that for the field names. Also variable i is not scope nor defined in the function. Usually this will default it to the variables scope but in a CFC this is not thread safe.
My guess is that you're going to need to learn ColdFusion as there is a good chance that correcting these issues will uncover other issues elsewhere in the code. I re-wrote the loadvars function but it was not tested, only eyeballed. You can try this but as I said, be prepared to learn CF.
<cffunction name="loadvars" output="false" returntype="clients">
<cfargument name="stValues" required="no" type="struct" />
<cfargument name="obj" required="no" type='cfc.clients' />
<cfset var fieldarray = 0>
<cfset var fieldname=0 />
<cfif not isdefined('arguments.obj')>
<cfset arguments.obj = createObject("component","cfc.clients").init() />
</cfif>
<!--- to hold form structure fieldnames --->
<cfif isdefined('arguments.stValues')>
<cfset fieldarray = structkeyarray(arguments.stValues) />
<cfif arraylen(fieldarray) gt 0>
<cfloop index="fieldname" array="#fieldarray#">
<cfif listFindNoCase("fieldnames,submit",fieldname) eq 0>
<cfset "arguments.obj.#fieldname#" = arguments.stValues[fieldname] />
</cfif>
</cfloop>
</cfif>
</cfif>
<cfreturn arguments.obj>
</cffunction>
Copy link to clipboard
Copied
You where right. I tried using your code and then received errors for the same lines, but about reCaptcha. I set my form back to the original with a Not Human slider -- which doesn't seem to work properly as the form submits without using the slider, but the firm does submit.
Next I tried replacing the Not Human slider with reCaptcha coding as used on other forms within the site. Sadly, now the form doesn't submit at all.
I have researched Honey Pot options, but the CF coding is way beyond me. The form in question uploads to a database. Do you hire out? If so, at what rate? And, can you ballpark the time that might be required to get this darn thing to submit WITH spam prevention of some sort?
Copy link to clipboard
Copied
I don't hire out but there are a few sites and forums where you can post what you're looking for. I have used freelancer.com before for logo design. I see some hits searching for coldfusion. Maybe after I retire I'll freelance but that probably won't help you in your project.
Copy link to clipboard
Copied
Thanks. I appreciate all your help.
Copy link to clipboard
Copied
It appears from your code logic that you are passing the form as the argument stValues of the function loadVars. Apparently, you wish to copy the form fields and their values to the respective properties in the clients component.
You could change slightly to something like
<cfloop from='1' to='#arraylen(fieldarray)#' index='i'>
<cfif findnocase('fieldnames',fieldarray) eq 0 and findnocase('submit',fieldarray) eq 0>
<cfset arguments.obj[fieldarray] = evaluate(fieldarray) >
</cfif>
</cfloop>
Copy link to clipboard
Copied
Tip:
In C:/inetpub/vhosts/designerbuilders.com/httpdocs/register.cfm, test using the code (after line 246):
<cfdump var="#serializeJSON(xclient)#" abort="true">