I think I have created a session Variable. Now, I want to be able to create a ContactType and apply the AccountID to the ContactType. The AccountID belongs to the user that has logged on (the session). How do I keep this session going? It seems to break when I Fill out a form and submit it. Note that my action page resides on the same page.
Here is the Form:
-------------------------
<CFQUERY NAME="GetAccount" DATASOURCE="#request.datasource#" DBTYPE="ODBC">
SELECT *
FROM Account
<cfif #session.AccountID# IS NOT 0>
WHERE AccountID = #Session.AccountID#
</cfif>
</CFQUERY>
<!-- FORM STARTS HERE -->
<FORM ACTION="#" METHOD="post">
<INPUT TYPE="hidden" NAME="AccountID" VALUE="#session.AccountID#">
<TABLE CELLSPACING="2" CELLPADDING="2" BORDER="0">
<TR>
<TD VALIGN="middle">Contact Type</TD>
<TD VALIGN="middle"><INPUT TYPE="text" NAME="ContactType" VALUE="" SIZE="25"></TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="center" VALIGN="top">
<BR>
<BR>
<INPUT TYPE="submit" NAME="Add" VALUE="Add"> <INPUT TYPE="reset" NAME="Reset" VALUE="Reset"></TD>
</TR>
</TABLE>
</FORM>
<!-- FORM ENDS HERE -->
---------------------------------
Then here is the code on the top of the page:
<CFIF IsDefined("FORM.add")>
<CFQUERY NAME="AddContactType" DATASOURCE="#request.datasource#" DBTYPE="ODBC">
INSERT INTO ContactType
(ContactType, AccountID)
VALUES ('#FORM.ContactType#', #FORM.AccountID#)
</CFQUERY>
</CFIF>
---------------------------
Any ideas?
Here is the Form:
-------------------------
<CFQUERY NAME="GetAccount" DATASOURCE="#request.datasource#" DBTYPE="ODBC">
SELECT *
FROM Account
<cfif #session.AccountID# IS NOT 0>
WHERE AccountID = #Session.AccountID#
</cfif>
</CFQUERY>
<!-- FORM STARTS HERE -->
<FORM ACTION="#" METHOD="post">
<INPUT TYPE="hidden" NAME="AccountID" VALUE="#session.AccountID#">
<TABLE CELLSPACING="2" CELLPADDING="2" BORDER="0">
<TR>
<TD VALIGN="middle">Contact Type</TD>
<TD VALIGN="middle"><INPUT TYPE="text" NAME="ContactType" VALUE="" SIZE="25"></TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="center" VALIGN="top">
<BR>
<BR>
<INPUT TYPE="submit" NAME="Add" VALUE="Add"> <INPUT TYPE="reset" NAME="Reset" VALUE="Reset"></TD>
</TR>
</TABLE>
</FORM>
<!-- FORM ENDS HERE -->
---------------------------------
Then here is the code on the top of the page:
<CFIF IsDefined("FORM.add")>
<CFQUERY NAME="AddContactType" DATASOURCE="#request.datasource#" DBTYPE="ODBC">
INSERT INTO ContactType
(ContactType, AccountID)
VALUES ('#FORM.ContactType#', #FORM.AccountID#)
</CFQUERY>
</CFIF>
---------------------------
Any ideas?