This document describes briefly some simple server-side scripts for testing HTML forms. Essentially, the scripts just echo back the data they receive.
This can be useful
The scripts mentioned here work both for METHOD="GET"
and for METHOD="POST".
My simple sendback script
(written in
Perl
using the
CGI.pm library)
echoes the data it gets, with field names in one column and and field
values in another column,
in monospaced font.
However, the data is decoded into plain text.
The script can handle forms with INPUT TYPE="FILE" fields
(i.e. forms with ENCTYPE="multipart/form-data") too.
To use the script, simply take
your FORM element and change the ACTION
attribute to
ACTION="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi"
<FORM ACTION="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi" METHOD="POST"> <P> Type something:<BR> <TEXTAREA ROWS=5 COLS=72 NAME=Comments> This is some text in several lines. </TEXTAREA> <p> <INPUT TYPE="checkbox" NAME="box" VALUE="yes">Check me! <P> <INPUT TYPE="HIDDEN" NAME="hidden field" VALUE="something"> <INPUT TYPE="SUBMIT" VALUE="Send"> </FORM>
Try it:
In some cases, you might wish to use an even simpler
script, namely
one that just echoes back the "raw" data
as plain text, assuming it has been sent using the "post"
method:
print "Content-Type: text/plain; charset=iso-8859-1\n\n";
print "Echoing raw form data:\n";
print;
while(<>) {
print; }
(The script is at
http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echoraw.cgi.
The code prepends the text Echoing raw form data:
and an empty line, so that you can distinguish between
server malfunction and lack of data).
This might be useful if you suspect that your browser cannot
send data properly encoded or that the library routine that your
script uses cannot decode it right.
TipJar's
test script echoes back more data such as HTTP headers.
The data is encoded, in the format
that the script receives it: in
application/x-www-form-urlencoded
format.
(The script cannot handle
forms with INPUT TYPE="FILE" fields,
i.e. forms with ENCTYPE="multipart/form-data".)
To use the script, simply take
your FORM element and change the ACTION
attribute to
ACTION="http://www.tipjar.com/cgi-bin/test"
Try it with
a variant of the form above (with just
the ACTION changed):