Insert into two tables cfif
I have a form with two fields that are added to one table each. One or both can be filled out and when the form is sent I am using the action code below. Am I do it correctly? Thanks:
<!--- If form is sent do the following --->
<cfif isDefined("form.updatebtn")>
<!--- If the sectors1 field is filled out do this--->
<cfif FORM.SECTORS1 GTE 1>
<CFQUERY name="addsector" datasource="salesdb">
INSERT INTO INDUSTRIES(
SECTORSNOM
)
VALUES (
<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#trim(form.SECTORS1)#" null="#isSECTORS1Null#" /> )
</CFQUERY>
<CFLOCATION URL="member_welcome.cfm">
<!--- If the department1 field is filled out do this--->
<cfelseif FORM.DEPARTMENT1 GTE 1>
<CFQUERY name="adddivision" datasource="salesdb">
INSERT INTO DIVISION(
DEPARTMENT1
)
VALUES (
<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#trim(form.DEPARTMENT1)#" null="#isDEPARTMENT1Null#" />
)
</CFQUERY>
<CFLOCATION URL="member_welcome.cfm">
<!--- If the both fields are filled out do this--->
<cfelse>
<CFQUERY name="addsector" datasource="salesdb">
INSERT INTO INDUSTRIES(
SECTORSNOM
)
VALUES (
<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#trim(form.SECTORS1)#" null="#isSECTORS1Null#" /> )
</CFQUERY>
<CFQUERY name="adddivision" datasource="salesdb">
INSERT INTO DIVISION(
DEPARTMENT1
)
VALUES (
<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#trim(form.DEPARTMENT1)#" null="#isDEPARTMENT1Null#" />
)
</CFQUERY>
</cfif>