2
votes

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
You should try to get a few answers before selecting the first one as the correct answer. In the future, you'll get more help. - Evik James

3 Answers

3
votes

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.

2
votes

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.

2
votes

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.