Solved

CF Form isn't updating field values into the database

Posted on 2006-11-08
7
149 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
Comment Utility
do you get any errors?

0
 

Author Comment

by:rudodoo
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 20

Expert Comment

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

Expert Comment

by:trailblazzyr55
Comment Utility
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
Comment Utility
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now