Skip to main content
Participant
January 14, 2013
Question

Form info sent to both an email and a database

  • January 14, 2013
  • 1 reply
  • 516 views

Someone know a good code that will allow a web base form be sent to an email and also a database?

    This topic has been closed for replies.

    1 reply

    WolfShade
    Legend
    January 14, 2013

    It's a simple matter to code.  Use both CFMAIL and CFQUERY on the same processing page.

    ^_^

    Participant
    January 14, 2013

    Hi Wolfshade, thankyou for looking at my question, as my name indicates I am not a great coder so if you could post a sample of using both on the processing page I would really appreciate it

    WolfShade
    Legend
    January 14, 2013

    If you want it sent to a static email address:

    <cfmail to="sendtouser@domain.com" subject="Email Form Data">

      #form.field1#

      #form.field2#

      ...

      #form.fieldn#

    </cfmail>

    <cfquery name="insertData" datasource="#yourDSN#">

      INSERT into tableA(columnA, columnB, columnC, columnD)

      VALUES(<cfqueryparam value="#form.field1#" cfsqltype="CFSQLVARCHAR">,<cfqueryparam value="#form.field2#" cfsqltype="CFSQLVARCHAR">,

                   <cfqueryparam value="#form.field3#" cfsqltype="CFSQLDATETIME">,<cfqueryparam value="#form.field4#" cfsqltype="CFSQLINTEGER">)

    </cfquery>