- Set the variables to use with the form under line
<cfparam name = "form.contactname" default = "" />
<cfparam name = "form.email" default = "" />
<cfparam name = "form.message" default = "" />
<cfparam name = "form.submitted" default = "0" />
- In the form set the tags names to the variables
<form id="form" action="/hello-world/contact.cfm" method="post">
<div>
<label>Name <span class="font-11">(required)</span></label>
<input name="contactname" type="text" class="required" />
</div>
<div>
<label>E-mail <span class="font-11">(required)</span></label>
<input name="email" type="text" class="required email" />
</div>
<div class="textarea">
<label>Message <span class="font-11">(required)</span></label>
<textarea name="message" rows="6" cols="60" class="required"></textarea>
</div>
<div>
<input id="submitBtn" value="Submit" name="submit" type="submit" class="submitBtn" />
</div>
<input type="hidden" name="submitted" value="1" />
</form>
- The action here is pointing to the same page. You can reference the values like this:
I'm using an if to display the values after the form was submitted to test if the variables are gettig fill
<cfif form.submitted>
<div>
<h3><cfoutput>#form.contactname#</cfoutput></h3>
<h3><cfoutput>#form.email#</cfoutput></h3>
<p><cfoutput>#form.message#</cfoutput></p>
</div>
</cfif>