View Single Post
Old 04-12-2010, 07:24 AM   PM User | #4
Gjslick
Regular Coder

 
Join Date: Feb 2009
Location: NJ, USA
Posts: 476
Thanks: 2
Thanked 70 Times in 69 Posts
Gjslick will become famous soon enough
Hey Suzy. I gotta tell ya, in all my 9 years of ColdFusion development, I have never once used the <cfinsert> tag! I had to look that one up for ya lol. Always just used direct querying instead.

But after checking it out, I don't think that it's going to work for you in this case. You might have to write out a full database INSERT statement in a <cfquery> tag.

Try this code:
Code:
<cfset dob = form.birthMonth & "/" & form.birthDay & "/" & form.birthYear>

<cfquery datasource="062105cs06sr">
    INSERT INTO users (
        username,
        createDate,
        password,
        firstName,
        lastName,
        dob,
        town,
        postcode,
        bio
    ) VALUES (
        <cfqueryparam value="#form.username#" cfsqltype="CF_SQL_VARCHAR">,
        <cfqueryparam value="#form.createDate#" cfsqltype="CF_SQL_DATE">,
        <cfqueryparam value="#form.password#" cfsqltype="CF_SQL_VARCHAR">,
        <cfqueryparam value="#form.firstname#" cfsqltype="CF_SQL_VARCHAR">,
        <cfqueryparam value="#dob#" cfsqltype="CF_SQL_DATE">,
        <cfqueryparam value="#form.town#" cfsqltype="CF_SQL_VARCHAR">,
        <cfqueryparam value="#form.postcode#" cfsqltype="CF_SQL_VARCHAR">,
        <cfqueryparam value="#form.bio#" cfsqltype="CF_SQL_VARCHAR">
    )
</cfquery>
The <cfqueryparam> tags are to validate data, and protect you from any SQL injection attacks. You can google that if ya like (can be a big database security issue), but suffice it to say, it is always best to use them

Hope that helps.

-Greg
Gjslick is offline   Reply With Quote
Users who have thanked Gjslick for this post:
suzierthanyou (04-12-2010)