CFMail Return to Form

252 views Asked by At

I have a form for feedback at the end of my webpage that is sent to my email address once it is filled out and submitted by users. The email sends, but the browser is sent to the cfm file. I'd like to be able to just hide the form and replace it with a thank you message. Is this possible? If not, just staying on the webpage where the form was would be ideal.

Thanks everyone.

3

There are 3 answers

1
Limey On BEST ANSWER

You can send the user where ever you want. Just use cflocation after the email is sent to send them somewhere, or keep them on the same page and just display a thank you message.

0
Tom Hubbard On

After a submit of data in general it is a good idea to use a redirect to avoid a second submit if the user hits refresh.

The cflocation tag will allow you to do this simply.

I would suggest you post your data to a "processing" cfm file (or, better yet cfc) and then use the cflocation tag to take you to the thank you page.

2
Evik James On

Many times, the form is submitted to the same page and a hidden form field that trips a subsequent if statement. Let's just say you are on the form.cfm page. You'd submit the form like this?

<form action="form.cfm">
<input type="hidden" name="ThisFormWasSubmitted">
 // form stuff
</form>

You can have an if statment above the form that either displays the form or displays a thank you for submitted the form, like this:

<cfif structKeyExists(FORM, "ThisFormWasSubmitted")>
    // process the form
    // show thank you message
<cfelse>
    // show the form
</cfif>

There are certainly dozens of varations of this.