NetTalk Central

Author Topic: Form Submit  (Read 3537 times)

elcidsps

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Form Submit
« on: May 15, 2009, 03:37:55 PM »
Greetings!

When I submit a form to a URL, how do I identify the fields and values submitted?  I tried p_web.GetValue('fieldname') but it returns nothing - though I know a value is there.  Any suggestions?

Thanks.

elcidsps

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Form Submit
« Reply #1 on: May 15, 2009, 07:05:59 PM »
***Update on this question:

I guess the reason why I am having difficulty getting the form parameters (which I found is by using p_web.getValue()), is becuase the post comes into the server as and XHR. Now the question is:

Is there a way to in NetTalk to parse this to get the field values from the form that is being posted?

Rob Mikkelsen

  • Full Member
  • ***
  • Posts: 107
    • Yahoo Instant Messenger - flashpott
    • View Profile
    • Email
Re: Form Submit
« Reply #2 on: May 16, 2009, 08:09:23 PM »
p_Web.GetValue() exists only for the life of the thread so, depending on how the next page is drawn, may not exist when you try to read it.  However, I believe that all the values are written to the session queue as well.  You should be able to find the data by using the p_Web.GSV method by using the variables or fields that you had defined on the form. 

In other words, if your field as defined on the web page is PHO:Number, you would request p_Web.GSV('PHO:Number') to retrieve it.  It is possible, of course, to redefine the session value by submitting another page so the sooner you can retrieve the value the more meaningful it is.

If you see underscores in the field name in the web source, don't worry about it.  NetTalk converts the field to PHO__Number on the web page but converts it back as soon as it parses the return value.

Rob

Alberto

  • Hero Member
  • *****
  • Posts: 1861
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Form Submit
« Reply #3 on: May 17, 2009, 10:22:57 AM »
Try  p_web.GetValue in the Restoremem procedure.

Cheers
Alberto
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11204
    • View Profile
Re: Form Submit
« Reply #4 on: May 17, 2009, 09:04:10 PM »
>> However, I believe that all the values are written to the session queue as well.

This isn't quite accurate. Moste values are _not_ written to the session queue. An exception are form fields - they're usually written to the session Queue.

The key thing with GetValue is that they only live for the life of the thread. So a good idea is to StoreValue any value you're expecting and then only use the GetSessionValue everywhere else.

If you're more specific as to the context of your question I can be more specific with the answer.

Cheers
Bruce

elcidsps

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Form Submit
« Reply #5 on: May 19, 2009, 11:13:47 AM »
Hey guys:

Update to this issue:

The XHR is sending and retrieving responses via the POST method, which does not pass the parameters around in constructive way for NetTalk.  I set the method to 'GET', which exposes the record data, but not to the web browser.....It allows me to read the parameters using the getValue function  Could this cause any collateral damage outside of an SSL connection?  Thanks.

Shawn

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11204
    • View Profile
Re: Form Submit
« Reply #6 on: May 19, 2009, 10:54:58 PM »
Hi Shawn,

I've not come across the term XHR before - but Wikipedia says it's an XMLHttpRequest. And that NetTalk is very familiar with since it's built using this a lot.

Using the POST method is no problem. NetTalk treats POSTs and GETs in much the same way. Parameters from both are decoded into the value queue.

That's assuming the POST is done using the regular PostData approach. However some apps send the Post data encoded, not in the normal HTTP way, but rather as an XML String. Sort of like an XML file tagged on the end of the POST header. 

In this case they _usually_ set the incoming Content-Type to xml. NetTalk spots this and creates a parameter for you called XML. ie
you can use p_web.GetValue('xml') to get the whole XML packet in your app.

Now if you're really unlucky it neither uses the normal POST encoding, nor sets the content-type to XML, and you need to manually decode the incoming request. Well you can access this text directly using
p_web.RequestData.DataString

Incidentally whether the site is SSL or normal HTTP is not important. The format of the incoming data won't be affected, and the content of he incoming data is not used, or inspected, by SSL.

I hope this helps, let us know if you need more.

Cheers
Bruce