Solved

CF Form isn't updating field values into the database

Posted on 2006-11-08
7
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
What You Need to Know when Searching for a Webhost Provider
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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