I would really appreciate it if someone could look at my code below and try to help me out. I have an application that is suppose to take info submitted in a form, update it to one table in the database and then pass variables via URL to another page where three pieces of info should be inserted into a different table in the database. My problem is that sometimes this whole process works perfectly and other times the info is not inserted into the second table. The update part of the process ALWAYS seems to work, but the insert part is very inconsistent. I'm stumped as to what may be causing the problem. I'll include my code below. I'd be very grateful for any help or suggestions you could offer.
thanks,
gwenn
This is the code that's doing the update and then you can see where the user gets redirected to ApplyOnline.cfm in the cflocation tag.
<!--- Update Resume Data --->
<CFIF Not CompareNoCase(form.action,'Update') OR Not CompareNoCase(form.action,'Save')>
<cfquery name="UpdateResume" datasource="#application.dsn#" dbtype="ODBC">
Update resumes
Set ractive = 1,
rbriefdes = '#form.rbriefdes#',
resumefile = '#variables.resumefile#',
rname = '#form.rname#',
typeid = #URL.typeid#,
rEmpType = '#form.remptype#',
rDriversLic = '#form.rdriverslic#',
rSSNum = '#form.rssNum#',
rAlienNum = '#form.ralienNum#',
rHighSchool = '#form.rHighSchool#',
rHSGradeComp = '#form.rHSGradeComp#',
rHSEquivDip = '#form.rHSEquivDip#',
rHSAddress = '#form.rHSAddress#',
rEmpPrefTitle = '#form.remppreftitle#',
rEmpDateAvail = '#form.rempDateAvail#',
rdismissed = #form.rdismissed#,
rCitizen = #form.rCitizen#,
rConvicted = #form.rconvicted#,
rDischarge = #form.rdischarge#,
rForcesActive = #form.rforcesactive#,
rTyping = #form.rtyping#,
rContactEmplr = #form.rcontactemplr#,
rHSGraduated = #form.rHSGraduated#,
rAffirmation = #form.raffirmation#,
rcontactins = '#form.rContactIns#',
rhowheard = '#form.rhowheard#',
rtypingtext = '#form.rtypingtext#',
rvisatype = '#form.rvisatype#',
rintentdate = '#form.rintentdate#',
rnydismissed = #form.rnydismissed#,
rnyguilty = #form.rnyguilty#,
rResign = #form.rResign#,
rResignText = '#form.rResignText#',
rDeniedten = #form.rDeniedten#,
rDeniedtenText = '#form.rDeniedtenText#',
rDismissedText = '#form.rDismissedText#',
rMilBranch = '#form.rMilBranch#',
rMilDates = '#form.rMilDates#',
rMilRank = '#form.rMilRank#',
rMilDischarge = '#form.rMilDischarge#'
Where resumeid = #URL.resid#
</cfquery>
<CFSET workingID = #URL.resid#>
<!--- Set Note --->
<CFSET note = 'Resume has been #form.action#'>
<!--- Remove all dead resumes --->
<cfquery name="DeadRes" datasource="#application.dsn#" dbtype="ODBC">
SELECT ResumeID From Resumes
WHERE rActive = 0
AND rName IS Null
AND rdate < #CreateODBCDate(DateAdd('H',-1,Now()))#
</cfquery>
<CFSET ResIDS = 0>
<CFIF Len(DeadRes.ResumeID)>
<CFSET ResIDs = #valuelist(DeadRes.ResumeID)#>
</CFIF>
<CFINCLUDE template="removeresumes.cfm">
<cfif not isDefined('URL.action')>
<!--- Check for Applying Online --->
<CFIF isDefined('URL.ADID')>
<cflocation url="ApplyOnline.cfm?AdID=#URL.ADID#&ResumeID=#URL.resid#" addtoken="No">
<cfabort>
<CFELSE>
<cflocation url="resumes.cfm?viewOK=1&MyResumes=1" addtoken="No">
<cfabort>
</CFIF>
</CFIF>
<!--- Remove Resume --->
<CFELSEIF Not CompareNoCase(form.action,'Remove')>
<!--- Remove Resume File--->
<CFIF Len(form.currentresumefile)>
<cffile action="DELETE" file="#thepath##form.currentresumefile#">
</CFIF>
<CFSET ResIDs = #URL.resID#>
<CFINCLUDE template="removeresumes.cfm">
<!--- Set workingid = 0 --->
<CFSET workingid=0>
<!--- Sete Note --->
<CFSET note = 'Resume has been Removed'>
<!---Relocate --->
<cflocation url="resumes.cfm?viewOK=1&MyResumes=1" addtoken="No">
</CFIF>
<!---Relocate --->
And then here's the ApplyOnline.cfm file with the INSERT Into that only works sometimes...
<!--- DID REQUIRED VARIABLES GET PASSED from MHCRP_App, et al.--->
<CFIF isDefined('URL.AdID') AND isDefined('URL.ResumeID')>
<!--- Initialize --->
<CFIF isDefined('URL.AdID') AND isDefined('URL.ResumeID')>
<cfparam name="variables.adid" default="#URL.AdID#">
<cfparam name="variables.Resumeid" default="#URL.ResumeID#">
<CFELSE>
<cfparam name="variables.adid" default="0">
<cfparam name="variables.Resumeid" default="0">
</CFIF>
<!--- Store Transaction in Applicants --->
<CFQUERY NAME="addApplicant" DATASOURCE="newaen1">
INSERT INTO Applicants (AdID, ResumeID, MemID)
Values(#variables.adid#, #variables.Resumeid#, #session.memberid#)
</CFQUERY>
<!--- Get data for Emailing --->
<!--- Get Job --->
<CFQUERY NAME="MyAd" DATASOURCE="newaen1">
SELECT *
FROM jobview
WHERE adid = #variables.adid#
</CFQUERY>
<!--- Get Resume --->
<CFQUERY NAME="Myresume" DATASOURCE="newaen1">
SELECT *
FROM resumeview
WHERE MemID = #session.memberid#
AND ResumeID = #variables.resumeID#
</CFQUERY>
<!--- Send Email --->
<CFINCLUDE Template="AppEmailSend.cfm">
<!--- Show Thank You --->
<CFINCLUDE Template="AppThankyou.cfm">
<!--- End Applicant processing --->
<CFELSE>
</CFIF>
thanks,
gwenn
This is the code that's doing the update and then you can see where the user gets redirected to ApplyOnline.cfm in the cflocation tag.
<!--- Update Resume Data --->
<CFIF Not CompareNoCase(form.action,'Update') OR Not CompareNoCase(form.action,'Save')>
<cfquery name="UpdateResume" datasource="#application.dsn#" dbtype="ODBC">
Update resumes
Set ractive = 1,
rbriefdes = '#form.rbriefdes#',
resumefile = '#variables.resumefile#',
rname = '#form.rname#',
typeid = #URL.typeid#,
rEmpType = '#form.remptype#',
rDriversLic = '#form.rdriverslic#',
rSSNum = '#form.rssNum#',
rAlienNum = '#form.ralienNum#',
rHighSchool = '#form.rHighSchool#',
rHSGradeComp = '#form.rHSGradeComp#',
rHSEquivDip = '#form.rHSEquivDip#',
rHSAddress = '#form.rHSAddress#',
rEmpPrefTitle = '#form.remppreftitle#',
rEmpDateAvail = '#form.rempDateAvail#',
rdismissed = #form.rdismissed#,
rCitizen = #form.rCitizen#,
rConvicted = #form.rconvicted#,
rDischarge = #form.rdischarge#,
rForcesActive = #form.rforcesactive#,
rTyping = #form.rtyping#,
rContactEmplr = #form.rcontactemplr#,
rHSGraduated = #form.rHSGraduated#,
rAffirmation = #form.raffirmation#,
rcontactins = '#form.rContactIns#',
rhowheard = '#form.rhowheard#',
rtypingtext = '#form.rtypingtext#',
rvisatype = '#form.rvisatype#',
rintentdate = '#form.rintentdate#',
rnydismissed = #form.rnydismissed#,
rnyguilty = #form.rnyguilty#,
rResign = #form.rResign#,
rResignText = '#form.rResignText#',
rDeniedten = #form.rDeniedten#,
rDeniedtenText = '#form.rDeniedtenText#',
rDismissedText = '#form.rDismissedText#',
rMilBranch = '#form.rMilBranch#',
rMilDates = '#form.rMilDates#',
rMilRank = '#form.rMilRank#',
rMilDischarge = '#form.rMilDischarge#'
Where resumeid = #URL.resid#
</cfquery>
<CFSET workingID = #URL.resid#>
<!--- Set Note --->
<CFSET note = 'Resume has been #form.action#'>
<!--- Remove all dead resumes --->
<cfquery name="DeadRes" datasource="#application.dsn#" dbtype="ODBC">
SELECT ResumeID From Resumes
WHERE rActive = 0
AND rName IS Null
AND rdate < #CreateODBCDate(DateAdd('H',-1,Now()))#
</cfquery>
<CFSET ResIDS = 0>
<CFIF Len(DeadRes.ResumeID)>
<CFSET ResIDs = #valuelist(DeadRes.ResumeID)#>
</CFIF>
<CFINCLUDE template="removeresumes.cfm">
<cfif not isDefined('URL.action')>
<!--- Check for Applying Online --->
<CFIF isDefined('URL.ADID')>
<cflocation url="ApplyOnline.cfm?AdID=#URL.ADID#&ResumeID=#URL.resid#" addtoken="No">
<cfabort>
<CFELSE>
<cflocation url="resumes.cfm?viewOK=1&MyResumes=1" addtoken="No">
<cfabort>
</CFIF>
</CFIF>
<!--- Remove Resume --->
<CFELSEIF Not CompareNoCase(form.action,'Remove')>
<!--- Remove Resume File--->
<CFIF Len(form.currentresumefile)>
<cffile action="DELETE" file="#thepath##form.currentresumefile#">
</CFIF>
<CFSET ResIDs = #URL.resID#>
<CFINCLUDE template="removeresumes.cfm">
<!--- Set workingid = 0 --->
<CFSET workingid=0>
<!--- Sete Note --->
<CFSET note = 'Resume has been Removed'>
<!---Relocate --->
<cflocation url="resumes.cfm?viewOK=1&MyResumes=1" addtoken="No">
</CFIF>
<!---Relocate --->
And then here's the ApplyOnline.cfm file with the INSERT Into that only works sometimes...
<!--- DID REQUIRED VARIABLES GET PASSED from MHCRP_App, et al.--->
<CFIF isDefined('URL.AdID') AND isDefined('URL.ResumeID')>
<!--- Initialize --->
<CFIF isDefined('URL.AdID') AND isDefined('URL.ResumeID')>
<cfparam name="variables.adid" default="#URL.AdID#">
<cfparam name="variables.Resumeid" default="#URL.ResumeID#">
<CFELSE>
<cfparam name="variables.adid" default="0">
<cfparam name="variables.Resumeid" default="0">
</CFIF>
<!--- Store Transaction in Applicants --->
<CFQUERY NAME="addApplicant" DATASOURCE="newaen1">
INSERT INTO Applicants (AdID, ResumeID, MemID)
Values(#variables.adid#, #variables.Resumeid#, #session.memberid#)
</CFQUERY>
<!--- Get data for Emailing --->
<!--- Get Job --->
<CFQUERY NAME="MyAd" DATASOURCE="newaen1">
SELECT *
FROM jobview
WHERE adid = #variables.adid#
</CFQUERY>
<!--- Get Resume --->
<CFQUERY NAME="Myresume" DATASOURCE="newaen1">
SELECT *
FROM resumeview
WHERE MemID = #session.memberid#
AND ResumeID = #variables.resumeID#
</CFQUERY>
<!--- Send Email --->
<CFINCLUDE Template="AppEmailSend.cfm">
<!--- Show Thank You --->
<CFINCLUDE Template="AppThankyou.cfm">
<!--- End Applicant processing --->
<CFELSE>
</CFIF>