I'm a stale programmer of 20 years ago who is trying to write a Windows application with an IE 4.0 HTML/DHTML/JavaScript front-end, and a Perl server.pl back-end, both on the same PC.
I use http://localhost:6789/ to send requests to Perl from the HTML pages. I know how to receive in my server.pl a GET request, and access the arguments passed in the query string.
I don't know how to do the same for a POST request, i.e. access the passed hidden variables, ostensibly from STDIN. For whatever it's value, I using a Windows 98 PC using ActiveState's Perl.
Here is the code around the processing of the GET and POST requests...
while ($client = $server->accept())
{
$client->autoflush(1);
$request = <$client>;
$request =~ tr/\x0d\x0a//d; # Remove and CR's and LF's
if ($request =~ m|^GET /(.*?)(\?(.*))? HTTP/1.[01]|)
{
# GET request
print STDERR "GET request\n";
$page = uri_unescape($1);
$querystring = uri_unescape($3);
PROCESS_REQUEST ();
}
elsif ($request =~ m|^POST /(.*) HTTP/1.[01]|)
{
# POST request
print STDERR "POST request\n";
$page = uri_unescape($1);
# How to read in the POST's passed hidden variables here ? ? ?
PROCESS_REQUEST ();
}
else
{
REDIRECT_TO_ERROR_PAGE ('Unprocessed request.');
}
close($client);
}
Any help greatly appreciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.