NetTalk Central

Author Topic: Form Method POST vs GET  (Read 3730 times)

elcidsps

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Form Method POST vs GET
« on: March 15, 2012, 10:49:43 AM »
Using NTWS.  If I submit a form with a method of "GET" I am able to read all the passed value pairs using the getValue() method.  Submitting the for via a POST method does not allow me to see the value pairs.  Is there a different method for getting the value parameters from a POST submit vs. a GET submit?  Thanks!!!

Flint G

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • Email
Re: Form Method POST vs GET
« Reply #1 on: March 15, 2012, 08:12:30 PM »
elcidsps -

You actually may use the exact same methods to retrieve the values.  Get vs. Post only describes the mechanism used by the browser to handle information.  While values may be passed via a GET, they are inherent and expected via a POST.

WebObject.GetValue('somevalue') will work both for GET and POST.

If you're not getting the right information from the GetValue() method in a POST, then you could look at what the server is actually receiving, and make certain that the value names and values are identical between your Get and Post.  Perhaps you start with the working GET, and then change the page to just do a POST instead, and see if that resolves the problem for you.

When all else fails, post an example  :)

Regards,
Flint
NetTalk: 12.26
Clarion: 9.1.11529
Brave: 1.31.88
Chrome: 95.0.4638.69
Edge: 95.0.1020.44
ExtJS: 7.0.0.156

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Form Method POST vs GET
« Reply #2 on: March 15, 2012, 09:46:11 PM »
which value are you trying to get. The only ones that "morph" with a POST are pressedbutton and _bidv_. As Flint says, the rest are all available with GetValue.

cheers
Bruce

elcidsps

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Form Method POST vs GET
« Reply #3 on: March 16, 2012, 04:19:56 AM »
Thanks for the response guys!

This is actually how I came across the problem.  Using the same form, I use a GET method and was able to read all the value pairs.  The ONLY thing I changed was the form method - changing it to a POST.

Sent to web server on a POST:
Code: [Select]
POST /loginprocess HTTP/1.1
Host: localhost:881
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://localhost:881/
Content-Length: 21
Cookie: SESSIONID=24973831
Pragma: no-cache
Cache-Control: no-cache

userid=33&password=33

Sent to web server on a GET:
Code: [Select]
GET /loginprocess?_dc=1331900230067&userid=ee&password=ee HTTP/1.1
Host: localhost:881
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
X-Requested-With: XMLHttpRequest
Referer: http://localhost:881/
Cookie: SESSIONID=24973831

I do know that if I were using PHP I would hae to parse the POST before I could read the values.  Any help would be appreciated.  Thanks.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Form Method POST vs GET
« Reply #4 on: March 16, 2012, 05:41:43 AM »
p_web.GetValue('userid')
and
p_web.GetValue('password')
should work the same in both cases.

>> I do know that if I were using PHP I would hae to parse the POST before I could read the values.

that's done for you, nothing to do...

If you still don't have any luck, post a small example.

Cheers
Bruce