Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This tests CFINSERT and CFUPDATE to see if they parameterise their values (http://bit.ly/MN0XYS)
<cfif structKeyExists(form, "btnSubmit")>
<cfif form.btnSubmit EQ "ADD">
<cfinsert tablename="tbl_test" datasource="scratch_mysql" formfields="tst_data">
<cfelseif form.btnSubmit EQ "UPDATE">
<cfupdate tablename="tbl_test" datasource="scratch_mysql" formfields="tst_id,tst_data">
</cfif>
</cfif>
<cfquery name="q" datasource="scratch_mysql">
SELECT tst_id, tst_data
FROM tbl_test
ORDER BY tst_id
</cfquery>
<!--- ADD A NEW ONE --->
<form method="post">
<input type="text" name="tst_data" value="" />
<input type="submit" name="btnSubmit" value="Add" />
</form>
<hr />
<!---UDPATE THE EXISTING ONES --->
<cfloop query="q">
<form method="post">
<cfoutput>
<input type="hidden" name="tst_id" value="#tst_id#" />
<input type="text" name="tst_data" value="#tst_data#" />
</cfoutput>
<input type="submit" name="btnSubmit" value="Update" />
</form>
<hr />
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment