Skip to content

Instantly share code, notes, and snippets.

@cocolote
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocolote/107ac15a2dfad5e6ca60 to your computer and use it in GitHub Desktop.
Save cocolote/107ac15a2dfad5e6ca60 to your computer and use it in GitHub Desktop.
The params array of CFML

Setting variables and sending values with forms CFML

  1. 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" />
  1. 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>
  1. 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment