Connecting Tech Pros Worldwide Help | Site Map

update database

Member
 
Join Date: Aug 2007
Posts: 80
#1: Dec 18 '07
Hi everyone, I've been messing around with coldfusion lately, and I'm having a rough time understanding how to update a database with the values of a form. I have some understanding of SQL, and it seems to me like I shouldnt have too much trouble with this, but I am. The way I have it now is;

Expand|Select|Wrap|Line Numbers
  1. <CFIF IsDefined("URL.Do")>
  2. <CFIF #URL.Do# IS "save">
  3. <CFQUERY DATASOURCE="scottersNew" NAME="allEmployeeQuery">
  4.    UPDATE employees, employeeInfo
  5.    SET firstName='#form.firstName#',
  6.    lastName='#form.lastName#',
  7.    phone='#form.age#',
  8.    idNumber='#form.idNumber#'
  9.    WHERE idNumber='#URL.ID#'
  10. </CFQUERY>
  11. </cfif>
  12. </cfif>
  13.  
Thats the update part, and the url is going through, but i always get the error "Element FIRSTNAME is unidentified in FORM".

I'm assuming that its a object oriented kinda thing like javascript. like document.form.value. Is that right, or is there some other meaning? What is the point of putting "form." in there is kinda what im getting at.


Thanks,
Scotter
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Dec 18 '07

re: update database


You use "form..." for POST form variables and "url..." for GET form variables. That's probably why it's not working. You're submitting your form with the GET method and checking for POSTed values.
Newbie
 
Join Date: Dec 2007
Posts: 5
#3: Dec 20 '07

re: update database


That's right. You should really use POST method for your form.
then you can operate on Form variables.
For GET, you should operate on URL variables.
Reply