cgi.lsp Patch HTTP POST parameter

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
unya
Posts: 27
Joined: Fri Feb 26, 2010 8:30 am
Contact:

cgi.lsp Patch HTTP POST parameter

Post by unya »

Hi all,

It is a patch that can get a POST Parameter for function CGI:get.

it works this form.

Code: Select all

<form action="/cgi-bin/post-data.cgi" method="POST" enctype="multipart/form-data">
<input type="checkbox" name="checkbox1" value="val1"/>val1<br/>
<input type="checkbox" name="checkbox1" value="val2"/>val2<br/>
<input type="checkbox" name="checkbox1" value="val3" checked/>val3<br/>

<input type="text" name="text1" size="30" maxlength="30" value="text sample">

<textarea name="textarea1" cols=40 rows=4>
abc
def
0123456789
</textarea>

<input type="submit" value="send"/>

Code: Select all

(println CGI:params) ;; context parameter(for debug)

(println "checkbox1=" (CGI:get "checkbox1") "<br/>")
(println "text1=" (CGI:get "text1")  "<br/>")
(println "textarea1=" (CGI:get "textarea1")  "<br/>")
Result

Code: Select all

params (("textarea1" "abc\r\ndef\r\n0123456789\r\n") ("text1" "text sample") ("checkbox1" "val3") ("checkbox1" "val2"))

checkbox1=val3
text1=text sample
textarea1=abc def 0123456789
TEXTAREA returns multi-line string, line separator is "\r\n", see Result "textarea1".

thanks,
new-cgi-module.zip
cgi.lsp (+ udiff), & test code(post.html, post-data.cgi)
(4.13 KiB) Downloaded 322 times

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: cgi.lsp Patch HTTP POST parameter

Post by Lutz »

Thanks Unya for the "multipart/form-data" content-type addition, the new cgi.lsp is online here:

http://www.newlisp.org/code/modules/cgi.lsp.html

Locked