Solved

CF Form isn't updating field values into the database

Posted on 2006-11-08
7
166 Views
Last Modified: 2013-12-24
I create this form that is supposed enable a user to insert records into a table.  However when I click on the save button it just takes me back to the action page without inserting the data.  I have the code that displays the form on one page and the qry to insert the form field values on another page.  Also, our company uses Oracle for its database

                                                                        HERE IS THE CODE FOR THE FORM PAGE

<cfinclude template="qry_update.cfm">

<cfform name="addrec" action="index.cfm?" method="post">
  <table width="379" border="1">
   <tr>
      <th scope="row"><div align="left">
        <!--- User inserts todays date here --->
        <label>Date
        <cfinput name="Date_Preapproval" validate="date" message="Please use the MM/DD/YYYY format for the date"
             type="text" value="#dateformat(now(),'MM/DD/YYYY')#" > 
        </label>
      </div></th>
    </tr>
   <tr><!--- Displays Vendor  --->
     <th scope="row"><div align="left">
       <label>Vendor
       <input type="text" name="Vendor" readonly="yes" value="<cfoutput>#request.vendornbr#</cfoutput>" />
       </label>
     </div></th>
   </tr>
    <tr><!--- Users Display name is inserted here --->
      <th scope="row"><div align="left">
        <label>Coordinator
        <input name="COORDINATOR" readonly="yes" type="text" id="coordinator" value="<cfoutput>#Request.logEmpname#</cfoutput>" />
        </label>
      </div></th>
    </tr>
    <tr><!--- Value can be null --->
      <th scope="row"><div align="left">
        <label>Contact Name
        <input name="CONTACTNAME"  type="text" id="contactname" maxlength="100" />
        </label>
      </div></th>
    </tr>
    <tr><!--- Value can be null --->
      <th scope="row"><div align="left">
        <label>Fax Number
        <input name="FAX" type="text" id="fax" maxlength="10" />
        </label>
      </div></th>
    </tr>
    <tr><!--- Value can be null --->
      <th scope="row"><div align="left">
        <label>Email
        <input name="EMAIL" type="text" id="email" maxlength="100" />
        </label>
      </div></th>
    </tr>
    <tr><!--- Integer Data type --->
      <th scope="row"><div align="left">
        <label>Expected Cost
        <input name="EXPECTEDCOST" type="text"  id="expectedcost" />
        </label>
      </div></th>
    </tr>
    <tr>
      <th scope="row"><div align="left">
        <label>Planned Activity
        <select name="EntryCode" id="EntryCode">
            <cfoutput query="plannedactivity">
            <option value="#entrycode#">#descr#</option>
            </cfoutput>
        </select>
        </label>
      </div></th>
    </tr>
    <tr><!--- Value can be null --->
      <th scope="row"><div align="left">
        <label>Price Point
        <input name="PRICEPOINT" type="text" id="pricepoint" />
        </label>
      </div></th>
    </tr>
    <tr>
      <th scope="row"><div align="left">
        <label>status
        <select name="STATUS" size="1" id="status">
             <cfoutput query="status">
             <option value="#status#">#status#</option>
             </cfoutput>
        </select>
        </label>
      </div></th>
    </tr>
    <tr>
      <th scope="row"><div align="left">
        <label>Notes
        <textarea name="notes" id="notes"></textarea>
        </label>
        </div></th>
    </tr>
    <tr>
      <th scope="row"><div align="left">
        <label>DateReceived
        <cfinput name="Date_received"  validate="date" message="Please use the MM/DD/YYYY format for the date" type="text" />
        </label>
      </div></th>
    </tr>
      <tr><input name="ActionDate" type="hidden" value="#dateformat(now(),'MM/DD/YYYY')#" />
            <input name="ActionUser" type="hidden" value="<cfoutput>#request.logemplid#</cfoutput>">
      <th scope="row"><input name="Save" type="submit" id="Save" value="Save">
        <input type="reset" name="reset" value="reset" />
      <td valign="bottom" rowspan="9">&nbsp;</td>
      </tr>
  </table>

</cfform>      

                                                                          HERE IS THE CODE FOR THE QRY PAGE

<!--- This query is used to display the planned activity values from the co-op entry codes table --->
<cfquery name="plannedactivity" datasource="#request.datasource#">
select entrycode, descr
from coop_entry_codes
order by entrycode
</cfquery>
<!--- Used to display the status list from the coop_status table --->
<cfquery name="status" datasource="#request.datasource#">
select status
from
(
select decode(status,'New',1,2) as colorder, status
from coop_status
)
order by colorder
</cfquery>
<!--- This query updates the coop_preapprovals table using the addrec form on the dsp_update page--->
<cfif isdefined('form.save')>
<cfquery datasource="#request.datasource#" name="update">
INSERT INTO COOP_PREAPPROVALS (
   PREAPPROVAL_ID,
   DATE_PREAPPROVAL,
   VENDOR,
   COORDINATOR,
   CONTACTNAME,
   FAX,
   EMAIL,
   EXPECTEDCOST,
   ENTRYCODE,
   PRICEPOINT,
   STATUS,
   NOTES,
   DATE_RECEIVED,
   ACTIONUSER,
   ACTIONDATE)
VALUES <!---The Coop_PreApprovals_ID is supposed to be automatically generated once the user clicks the save button on the form--->
(COOP_PREAPPROVALS_SEQ.nextval,
#Form.Date_Preapproval#,
'#Form.Coordinator#',
'#Form.ContactName#',
'#Form.Fax#',
'#Form.Email#',
'#Form.ExpectedCost#',
'#Form.EntryCode#',
'#Form.PricePoint#',
'#Form.Status#',
'#Form.Notes#',
#Form.Date_Received#,
'#Form.ActionUser#',
#Form.ActionDate#)
</cfquery>
</cfif>

Does anyone have any suggestions?
0
Comment
Question by:rudodoo
  • 3
  • 2
7 Comments
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 17900769
do you get any errors?

0
 

Author Comment

by:rudodoo
ID: 17901115
I wasn't before but now I made some corrections.  And I receive this error

 unique constraint (TableName.PK_COOP_PREAPPROVALS) violated  
 
0
 

Author Comment

by:rudodoo
ID: 17901376
I solved the problem, what happened was that I wasn't using CGI.Variable scripts in the cfform action tag.  Everything works now. Please close this question
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 17901434
cool, glad you figured it out ;o)
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 17916493
I agree to PAQ/Refund, rudodoo was able to solve the issue, no help needed from me. rudodoo provided the solution on 11/08/2006 12:26PM PST and has responded to comments..

regards,
~trail
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17964390
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question