Reading New Value from a Form

Topics: Developer Forum
May 29, 2009 at 5:16 PM

Hi all:

I created a template and have linked it to the main.prg in the project. my problem however is that I don't seem to be able to pass new values from the form to the program.

e.g if the form comes up with say a Last Name of "Brown" and I try to change it to "Brown2" the updates or insert would still reflect "Brown"

could anyone indicate what setting or whatever else I may have missed.

 Thanks

Coordinator
May 29, 2009 at 6:31 PM

If there aren't any error messages, I would assume it's updating a copy of that file somewhere.  It sounds like your data path is not what you expect it to be.  You can hardcode the data path in the init of the main.prg.

May 29, 2009 at 7:22 PM

I would agree except that there is only 1 instance of the table on the computer. but even so it finds and displays the correct record but does not do the updates or inserts.

Note also that I used NVL() because I was getting a "field cannot acept null values" in the insert section but after using NVL() the field is updated but with the substitute values in the NVL()

I was wondering if there was a setting to tell the read the values again when the submit button is clicked.

here is my code

FUNCTION bptaData
LOCAL lcHTMLfile,lcHTMLout,lcMembID
*lcMembID=oRequest.querystring("email")
lcMembID="cpu_ja@yahoo.com"
IF .NOT. USED('dataform')
 USE ('dataform') IN 0 SHARED
ENDIF

SELECT dataform
**************

SET ORDER TO email
SEEK PADR(lcMembID,LEN(dataform.email),' ')
IF EOF()
 SELECT * FROM title INTO CURSOR csrTitle
 ctitle=oHTML.HTMLdropDown('csrTitle.title','csrTitle.title','salu','Select a Title',oSession.VALUE("salu"),.F.)
 
 SELECT * FROM tblgnder INTO CURSOR csrgender
 
 cgender=oHTML.HTMLdropDown('csrGender.sex','csrGender.sex','mlfl','Select a Gender',oSession.value('mlfl'),.F.)

 SELECT * FROM tblparish INTO CURSOR csrparish
 cparish=oHTML.HTMLdropDown('csrParish.parish','csrParish.parish','fld_parish','Select a Parish',oSession.value('fld_parish'),.F.)

 oSession.VALUE("lname",oRequest.FORM(dataform.lname))
 oSession.VALUE("fname",oRequest.FORM(dataform.fname))
 oSession.VALUE("email",oRequest.FORM(dataform.email))
 oSession.VALUE("salu",oRequest.FORM(dataform.title))
 oSession.VALUE("mlfl",oRequest.FORM(dataform.gender))
 oSession.VALUE("fld_parish",oRequest.FORM(dataform.addr_prsh))

 SELECT dataform
 
 INSERT INTO dataform (lname,fname,email,title,gender,addr_prsh) VALUES ;
 (NVL(oSession.VALUE("lname"),"LastName"),NVL(oSession.VALUE("fname"),"MyName"),NVL(oSession.VALUE("email"),"email"),NVL(oSession.VALUE("salu"),"Salu"),;
 NVL(oSession.VALUE("mlfl"),"MaleFemale"),NVL(oSession.VALUE("fld_parish"),"Parish"))

*!*  UPDATE dataform SET ;
*!*  lname=oSession.VALUE("lname"),;
*!*  fname=oSession.VALUE("fname"),;
*!*  email=oSession.VALUE("email"),;
*!*  title=oSession.VALUE("salu"),;
*!*  gender=oSession.VALUE("mlfl"),;
*!*  addr_prsh=oSession.VALUE("fld_parish");
*!*  WHERE lname=PADR(oSession.VALUE("lname"),LEN(dataform.lname),' ')

 
 lcHTMLfile = 'bpdata.htm'
 lcHTMLout=FILETOSTR(oProp.HtmlPath+lcHTMLfile)
 lcHTMLout= oHTML.mergetext(lcHTMLout)
  *lcHTMLout=(lcMembid)


ELSE
 lcHTMLout= 'This email address is already Registered'
 oSession.VALUE("lname",ALLTRIM(dataform.lname))
 oSession.VALUE("fname",ALLTRIM(dataform.fname))
 oSession.VALUE("email",ALLTRIM(dataform.email))
 oSession.VALUE("salu",ALLTRIM(dataform.title))
 oSession.VALUE("mlfl",ALLTRIM(dataform.gender))
 oSession.VALUE("fld_parish",ALLTRIM(dataform.addr_prsh))
 
 SELECT * FROM title INTO CURSOR csrTitle
 ctitle=oHTML.HTMLdropDown('csrTitle.title','csrTitle.title','salu','Select a Title',oSession.VALUE("salu"),.F.)
 
 
 SELECT * FROM tblgnder INTO CURSOR csrgender
 cgender=oHTML.HTMLdropDown('csrGender.sex','csrGender.sex','mlfl','Select a Gender',oSession.value('mlfl'),.F.)
 
 SELECT * FROM tblparish INTO CURSOR csrparish
 cparish=oHTML.HTMLdropDown('csrParish.parish','csrParish.parish','fld_parish','Select a Parish',oSession.value('fld_parish'),.F.)

 UPDATE dataform SET ;
 lname=oSession.VALUE("lname"),;
 fname=oSession.VALUE("fname"),;
 email=oSession.VALUE("email"),;
 title=oSession.VALUE("salu"),;
 gender=oSession.VALUE("mlfl"),;
 addr_prsh=oSession.VALUE("fld_parish");
 WHERE ALLTRIM(lname)=ALLTRIM(oSession.VALUE("lname"))
 *WHERE ALLTRIM(STR(membid))="1"  &&ALLTRIM(lname)=ALLTRIM(oSession.VALUE("lname"))

 lcHTMLfile = 'bpdata.htm'
 lcHTMLout=FILETOSTR(oProp.HtmlPath+lcHTMLfile)
 lcHTMLout= oHTML.mergetext(lcHTMLout)
 
ENDIF
RETURN lcHTMLout

ENDFUNC  

Coordinator
May 29, 2009 at 8:06 PM

More than likely it's your Update sql.  Try to simplify it if possible or update one field or ..something to verify it's actually getting to that table. 

If it were a user rights issue I always get an error message.  If that were the case I'd be telling you to look at the rights for that table and compare them to the rights in the installed example tables.  But it's not so I won't..

May 29, 2009 at 10:46 PM

I'm going to try a different approach but can you help me with this syntax

action="http://192.168.0.15/Bpta/default.aspx?action=bptaRev&lcMembId=cpu_ja@yahoo.com"

If I have a text box on the form that contains the email address how would I modify the above syntax to substitute the email address in the string.

 

Thanks

May 30, 2009 at 1:40 AM

Got both of them

1 should be l_lcMembID=oRequest.Form("email") instead of oSession.VALUE("email",oRequest.FORM(dataform.email))

2. <%email%> works

Thanks

Coordinator
May 30, 2009 at 10:47 AM

glad you got this.  Using the SESSION object is optional and would save and store the email temporarily until the user confirms.  So, in the example, whatever the user entered is retrieved with the regular oRequest.FORM(dataform.email) and stored in the session temporarily with oSession.VALUE("email",oRequest.FORM(dataform.email))