Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7027839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:18:05+00:00 2026-05-28T00:18:05+00:00

It has recently been mentioned to be that our method of inserting data into

  • 0

It has recently been mentioned to be that our method of inserting data into our SQL database via form submission is subject to SQL injection attacks, and want some advice to harden our security.

Here’s the code that inserts form data into the DB:

        <cfquery name="InsRegistrant" datasource="#application.Datasource#" dbtype="odbc">

            INSERT INTO Schedule_Registrations(
                schedule_id,
                first_name,
                last_name,
                phone_number,
                email,
                guest,
                list_type,
                datetime_registered
             )
            VALUES(
                #url.schedule_id#,
                '#FORM.first_name#',
                '#FORM.last_name#',
                '#CleanPhoneNumber#',
                '#FORM.email#',
                 #attendee.guest#,
                 <!--- Values for list types 
                    0 = NEVER USE Will cause many many problems
                    1 = Main List
                    2 = Waiting List --->                    
                 #attendee.list_type#,
                 #createodbcdatetime(now())#
             )                
        </cfquery>

CleanPhoneNumber is set this way:

<cfset CleanPhoneNumber = REReplace(form.phone_number, "[^0-9]", "", "ALL") />

I’ve been told to use, for instance,

<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.phone_number#" />

but I’m not sure what to replace and where. When I replace the values with such I get an error.

Any direction would be helpful..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:18:06+00:00Added an answer on May 28, 2026 at 12:18 am

    You should wrap all form and url variables in cfqueryparam

    Your query would look like this:

    <cfquery name="InsRegistrant" datasource="#application.Datasource#" dbtype="odbc">
        INSERT INTO Schedule_Registrations(
             schedule_id,
             first_name,
             last_name,
             phone_number,
             email,
             guest,
             list_type,
             datetime_registered
         )
         VALUES(
             <cfqueryparam cfsqltype="cf_sql_integer" value="#url.schedule_id#">,
             <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.first_name#">,
             <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.last_name#">,
             <cfqueryparam cfsqltype="cf_sql_varchar" value="#CleanPhoneNumber#">,
             <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.email#">,
             <cfqueryparam cfsqltype="cf_sql_integer" value="#attendee.guest#">,
             <!--- Values for list types 
                0 = NEVER USE Will cause many many problems
                1 = Main List
                2 = Waiting List --->                    
             <cfqueryparam cfsqltype="cf_sql_integer" value="#attendee.list_type#">,
             #createodbcdatetime(now())#
         )                
    </cfquery>
    

    I’m not sure I got all the data types correct, see the full documentation of cfqueryparam for all the data types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My database has recently been hacked by SQL injection leaving tags throughout data in
Our team has recently been working on a logic and data layer for our
Recently our site has been deluged with the resurgence of the Asprox botnet SQL
We have an SQL contacts database that links into all our project information with
Our team has recently been considering pushing out a minor registry fix to users
I have an international company that has recently been added, which is named BLA
I am working on extending the spell checker that has recently been updated on
Our business currently has an online store and recently we've been offering free specials
Attempting to do SetData() on Texture2D that has been recently Draw()-n by SpriteBatch leads
howzit! I'm a web developer that has been recently requested to develop a Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.