# why I cannot insert '#Form.Email#'

**URL:** <https://dev.lucee.org/t/why-i-cannot-insert-form-email/14916>\
**Category:** dev\
**Created:** [March 31, 2025, 1:12pm UTC](https://dev.lucee.org/t/why-i-cannot-insert-form-email/14916 "2025-03-31T13:12:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward](https://dev.lucee.org/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Edward](https://dev.lucee.org/u/Edward)\
**Post date:** [March 31, 2025, 1:12pm UTC](https://dev.lucee.org/t/why-i-cannot-insert-form-email/14916/1 "2025-03-31T13:12:49Z")

</div>

I have a CF page “MemberExpress” like below

…

…

**My Email:**

…

…

…

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

INSERT INTO Members (HandleName, Age, BirthYear, State, CCountry, Email)

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

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

INSERT INTO Members (HandleName, Age, BirthYear, State, CCountry, Email)

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

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,

---

<div class="post-metadata">

**Author:** ![Zackster](https://dev.lucee.org/user_avatar/dev.lucee.org/zackster/32/3484_2.png) [@Zackster](https://dev.lucee.org/u/Zackster)\
**Post date:** [March 31, 2025, 1:19pm UTC](https://dev.lucee.org/t/why-i-cannot-insert-form-email/14916/2 "2025-03-31T13:19:28Z")

</div>

if you look in lucee-server\context\logs\exception.log you should see the error, sounds like you have some error handling in place, hiding the actual error which is great on prod but sucks in local dev.

I have also written a log viewer extension for the admin

> **[GitHub - zspitzer/lucee-logviewer: Log viewer administrator extension for Lucee](https://github.com/zspitzer/lucee-logviewer)**
>
> Log viewer administrator extension for Lucee

you should always be using `cfqueryparam` for all user supplied data\* going into a sql query, otherwise you can be easily hacked via **sql injection attacks**

- also for trusted data, the database engine can cache they query plan and will run faster, basically any variables being passed into a query should be passed (bound) via `cfqueryparam`

> **[cfqueryparam :: Lucee Documentation](https://docs.lucee.org/reference/tags/queryparam.html#examples)**
>
> Checks the data type of a query parameter.

The same goes for displaying data, always use `encodeForHtml` when outputting data, otherwise, it’s easily for anyone to XSS your wesbite

> **[EncodeForHTML() :: Lucee Documentation](https://docs.lucee.org/reference/functions/encodeforhtml.html)**
>
> Encodes the given string for safe output in HTML to reduce the risk of Cross Site Scripting attacks.

OWSAP maintain a nice list of things to be aware of

[https://top10proactive.owasp.org/](https://top10proactive.owasp.org/)

---

<div class="post-metadata">

**Author:** ![kenricashe](https://dev.lucee.org/user_avatar/dev.lucee.org/kenricashe/32/3476_2.png) [@kenricashe](https://dev.lucee.org/u/kenricashe)\
**Post date:** [April 2, 2025, 7:21pm UTC](https://dev.lucee.org/t/why-i-cannot-insert-form-email/14916/3 "2025-04-02T19:21:00Z")

</div>

I also highly recommend using pure cfscript instead of cfml tags for all business logic, then you can use QueryExecute() which simplifies the secure query params.

Example (with Arguments scope for the params assuming the Form values are passed into a cfc component function):

```auto
QueryExecute(
  "
    insert into Members (HandleName, Age, BirthYear, State, CCountry, Email)
    values (:HandleName, :Age, :BirthYear, :State, :CCountry, :Email)
  ",
  {
    "HandleName": {"value": Arguments.HandleName, "sqltype": "varchar"},
    "Age": {"value": Arguments.Age, "sqltype": "varchar"},
    "BirthYear": {"value": Arguments.BirthYear, "sqltype": "varchar"},
    "State": {"value": Arguments.State, "sqltype": "varchar"},
    "CCountry": {"value": Arguments.CCountry, "sqltype": "varchar"},
    "Email": {"value": Arguments.Email, "sqltype": "varchar"}
  }
);

```

---

<div class="post-metadata">

**Author:** ![BK\_BK](https://dev.lucee.org/user_avatar/dev.lucee.org/bk_bk/32/3450_2.png) [@BK\_BK](https://dev.lucee.org/u/BK_BK)\
**Post date:** [April 7, 2025, 4:13pm UTC](https://dev.lucee.org/t/why-i-cannot-insert-form-email/14916/4 "2025-04-07T16:13:02Z")

</div>

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.
