Box 24

 Home   Infos   Tipps   Webmail   Humor   Polizei   Gästebuch   Downloads   Chat   Suchen   Feedback   Links 

 

 Anmelden/Login   Neuanmeldung/New User   Java Telnet Applet   Telnet   
 

WCX Form processing reading parameters

The following WCC program shows how to read parameters.

This is the source to HTML-URL TESTER.WCC:

// example application showing how to read parameters

#include "htmlutil.wch"

print "<XMP>"
print "Original URL  : [";HttpRequestUrl();"]"
print "Request Type  : [";HttpRequestMethod();"]"
print "Encode Type   : [";HttpRequestEncodeType();"]"
print

print "---- Parameter Dump -----"

dim i as integer
for i = 0 to paramcount
   print "paramstr(";i;"): [";paramstr(i);"]"
next
print

dim nvPairs as string

// There are basically 3 ways to read name=value pairs passed by
// by a web form
// method 1: FORM action=GET
//
// If you using a FORM action="GET", then the web server will pass
// the unescaped NAME=VALUE pairs in paramstr(1). You then use
// the GetParamStr() function to read each field.
//
// NOTE: You can't use use this method if the aciton="POST"
//

print "--- nvPairs = paramstr(1) ----"

nvPairs  = paramstr(1)

print "nvPairs       : [";nvPairs;"]"
print "s1: [";GetParamStr(nvPairs,"s1","n/a");"]"
print "s2: [";GetParamStr(nvPairs,"s2","n/a");"]"
print "s3: [";GetParamStr(nvPairs,"s3","n/a");"]"
print

// method 2: FORM action=GET
//           FORM action=POST
//
// If you expect to use a FORM action="POST", the web server will
// write the data to a file and pass the file name in paramstr(1)
// The best way to read the file to create the NAME=VALUE pairs
// is to use the GetPostVars() function. By using GetPostVars()
// you can handle a GET or a POST.
//
// NOTE: You can't use use this method if the FORM action=POST
// and enctype="multipart/form-data".

print "--- nvPairs = GetPostVars(paramstr(1)) ----"

nvPairs  = GetPostVars(paramstr(1))

print "nvPairs       : [";nvPairs;"]"
print "s1: [";GetParamStr(nvPairs,"s1","n/a");"]"
print "s2: [";GetParamStr(nvPairs,"s2","n/a");"]"
print "s3: [";GetParamStr(nvPairs,"s3","n/a");"]"
print

// method 2: FORM action=GET
//           FORM action=POST
//           FORM action=POST encytype="multipart/form-data"
//
// However, there is a special POST where enctype="multipart/form-data".
// This enctype is mostly used when uploading files. In WCX, you
// use the PrepareHTTPRequestData() function to handle this type
// of enctype type.
//
// By using this function, you can handle ALL 3 situations, GET,
// POST and POST with encytype="multipart/form-data"

print "--- Using PrepareHTTPRequestData(paramstr(1),nvPairs) ----"

if PrepareHTTPRequestData(paramstr(1),nvPairs) then
   print "This was POSTED data"
else
   print "This was GET data"
end if

print "nvPairs       : [";nvPairs;"]"
print "s1: [";GetParamStr(nvPairs,"s1","n/a");"]"
print "s2: [";GetParamStr(nvPairs,"s2","n/a");"]"
print "s3: [";GetParamStr(nvPairs,"s3","n/a");"]"
print

print "</XMP>"

Test it here.

© 2002 Hector Santos, http://www.santronics.com