Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

why I cannot insert '#Form.Email#'

New Here ,
Mar 30, 2025 Mar 30, 2025

I have a CF page "MemberExpress" like below


<cfFORM ACTION="MemberExpressRegActionPage.cfm" method="post">

..........

........

<dd><B>My Email:</b><cfINPUT TYPE="text" size="30" name="Email" message="Please enter your email address." required="yes" >

....

.....

......

</cfform>

 

In the page MemberExpressRegActionPage.cfm, I have this like below

 

<CFQUERY NAME="AddAppMemTable" DATASOURCE="MEM">
INSERT INTO Members
(HandleName, Age, BirthYear, State, CCountry, Email)

VALUES
('#Form.HandleName#', '#Form.Age#', '#Form.BirthYear#', '#Form.State#', '#Form.CCountry#', '#Form.Email#')

</CFQUERY>

 

The page cannot be posted sucessfully with error "An error occurred while executing the application. Please try again or contact the administrator."

 

The issue is I cannot insert '#Form.Email#' value into the database 

If I remove '#Form.Email#' in page MemberExpressRegActionPage.cfm , I can insert sucesffully without issue. But if I include '#Form.Email#', the page doesnt work.

Also, if in page MemberExpressRegActionPage.cfm, I put an exact value like belwo, it works

 

<CFQUERY NAME="AddAppMemTable" DATASOURCE="MEM">
INSERT INTO Members
(HandleName, Age, BirthYear, State, CCountry, Email)

VALUES
('#Form.HandleName#', '#Form.Age#', '#Form.BirthYear#', '#Form.State#', '#Form.CCountry#', 'abc65432@yahoo.com')

</CFQUERY>

 

I spent hours to trooubleshooot, I have no clue what went wrong. Can someone help me? Also, how to debug what's wrong with it.

 

Thanks,

 

 

129
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 30, 2025 Mar 30, 2025

This can be resolved and can be debugged--multiple ways. 

 

First, you need to know the actual error. What you quote ("An error occurred while executing the application. Please try again or contact the administrator.") is NOT a cf error. Instead it's something being put out to the user by your app's error handler: that may be implemented as either a try/catch around this code, or an application-level error handler (cferror in application.cfm or onerror in application.cfc), or a

site-wide handler defined in the cf admin. Sadly, such error handlers keep cf from writing the error to the cf application.log and coldfusion-out.log as would normally happen. FWIW, that error handler MIGHT also be writing the actual error to its own log file, or to a database, or an email--or you should get it to do one of those things, to help know the error details. You may also find details in the cf exception.log.

 

Short of that, to debug this yourself, put a cfdump of the form scope above the cfquery, followed by anl cfabort. Is the email field shown there? Does it have the value you expect? Don't trust that you "showed us the cfform with the cfinput". Verify it.

 

And if it does have a value, put THAT value into that hard-coded insert value. Does the cfquery now fail?  If so, what's the error?

 

Note that you could wrap that cfquery in a cftry/cfcatch, and then you could output the error to see its detail. (This would supercede the other error handler that's HIDING the error from you.)

 

Let us know how things go. 


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2025 Mar 31, 2025

Like Charlie, I think that something other than the form is causing the problem.

 

Anyway, some immediate questions, just for clarity. Firstly, is the page actually called "MemberExpress.cfm ", not "MemberExpressReg.cfm"? I ask because the name of the action page is "MemberExpressRegActionPage.cfm".  Secondly, are the pages MemberExpress.cfm and MemberExpressRegActionPage.cfm within the same directory? They should be.

 

From the error message, it seems as if ColdFusion isn't even able to compile the CFM page. I would therefore suggest that you do the following test.

 

1.  Save this code as the page memberExpress_Test.cfm:

<!--- Location: within the same directory as the page memberExpress.cfm --->
<cfform action="memberExpressRegActionPage_Test.cfm" method="post">
<b>My Email:</b><cfinput TYPE="text" size="30" name="Email" message="Please enter your email address." required="yes"><br>
<b>My HandleName:</b><cfinput TYPE="text" size="30" name="HandleName" message="Please enter your HandleName." required="yes"><br>
<b>My Age:</b><cfinput TYPE="text" name="Age" message="Please enter your Age." required="yes"><br>
<b>My BirthYear:</b><cfinput TYPE="text" name="BirthYear" message="Please enter your BirthYear." required="yes"><br>
<b>My State:</b><cfinput TYPE="text" name="State" message="Please enter your State." required="yes"><br>
<b>My Country:</b><cfinput TYPE="text" name="CCountry" message="Please enter your Country." required="yes"><br><br>
<cfinput name="submit" value="Submit" type="submit">
</cfform>

 

2.  Save this code as the page memberExpressRegActionPage_Test.cfm

<!--- Location: within the same directory as the page memberExpress.cfm --->

<cfdump var="#form#" label="Submitted form data">

<!--- 
The following query assumes that the datatype of each column is Varchar. 
I expected Age and BirthYear to be numeric. If they indeed are,
then change their cfsqltype to "cf_sql_integer" or "cf_sql_numeric"
--->
<CFQUERY NAME="AddAppMemTable" DATASOURCE="MEM">
	INSERT INTO Members
	(HandleName, Age, BirthYear, State, CCountry, Email)
	VALUES (
	      <cfqueryparam value="#Form.HandleName#" cfsqltype="cf_sql_varchar">,
		  <cfqueryparam value="#Form.Age#" cfsqltype="cf_sql_varchar">,
		  <cfqueryparam value="#Form.BirthYear#" cfsqltype="cf_sql_varchar">,
		  <cfqueryparam value="#Form.State#" cfsqltype="cf_sql_varchar">,
		  <cfqueryparam value="#Form.CCountry#" cfsqltype="cf_sql_varchar">,
		  <cfqueryparam value="#Form.Email#" cfsqltype="cf_sql_varchar">
	)
</CFQUERY>

Now verify whether the values have been inserted into AddAppMemTable

 

If the test works, then copy the test code to your application. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 03, 2025 Apr 03, 2025

@edwardc31059320 , I see elsewhere that your form is now working. Can you please share with us what the solution was?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2025 Apr 07, 2025
LATEST

I have just seen this same question on the Lucee website. The information has given me a new idea.

 

The problem is probably not with the action page, but with the form page. For some reason, the form might not be submitting the email field. So check the form. Make sure nothing prevents it from submitting the email field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources