Form submission to a CFC
Hello,
I am trying to create a form that submits the data to a cfc and then once submitted to just display a message where the form used to be to say "Thank you for submitting your data".
Here is what i have so far, but first i can't even get the data to submit to the cfc and then i don't know how to keep them on the same page but just change where the form used to be to just display a message once the data is submitted.
<!--- Form --->
<cfform action="cfc.test?method=insert" method="post">
<table align="center">
<tr>
<td>First Name</td>
<td><cfinput type="text" name="fname" required="yes" message="Please enter a valid first name."></td>
</tr>
<tr>
<td>Last Name</td>
<td><cfinput type="text" name="lname" required="yes" message="Please enter a valid last name."></td>
</tr>
<tr>
<td>Email</td>
<td><cfinput type="text" name="email" required="yes" validate="email" message="Please enter a valid email address."></td>
</tr>
<tr>
<td>Phone</td>
<td><cfinput type="text" name="phone" required="yes" validate="telephone" message="Please enter a valid telephone number."></td>
</tr>
<tr>
<td colspan="2"><cfinput type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</cfform>
<!--- CFC --->
<cfcomponent>
<cffunction name="insert" access="remote" returntype="void">
<cfargument name="fname" type="string" required="yes">
<cfargument name="lname" type="string" required="yes">
<cfargument name="email" type="string" required="yes">
<cfargument name="phone" type="string" required="yes">
<cfquery name="insertData" datasource="#application.dsn#">
INSERT INTO tbl_data
VALUES('#arguments.fname#','#arguments.lname#','#arguments.email#','#arguments.phone#')
</cfquery>
</cffunction>
</cfcomponent>
