GETS and POSTS and existing query strings
"Tuc at T-B-O-H.NET" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <200801162341.m0GNfjma049845@himinbjorg.tucs-beachin-obx-house.com> |
Hi,
I've got a unique situation I need some advice on. I have a program
that reads a webpage, and strips all the html out of it to make each link
something like :
http://www.example.com/cgi-bin/example.pl?next=wtgb435&sid=g2245er
Program uses LWP and works like a champ.
So next I wanted to move into having it handle forms. This is
where I'm running into a problem.
If I try to view a GET, I end up with :
email
Submit
Key - email / Data - GETIT
Key - Submit / Data - Send
email=GETIT&Submit=Send
Which I lose my information completely.
If I use a POST, I end up with :
email
Submit
Key - email / Data - POSTIT
Key - Submit / Data - Send
next=W9vmYnV8NW0nJ4Vvmt2vGpwvouo281wP&sid=8TviPDfR4LhVA5WvjPr63Ppm2aPWMiNl
Which I get my data in the QUERY_STRING, and the other data via
the params.
Is there a way I can uniformly get what I need, regardless of a
GET or a POST?
Thanks, Tuc
CGI:
#!/usr/bin/perl
use CGI;
$cgiinfo= new CGI;
@paramnames = $cgiinfo->param;
print "Content-Type: text/plain; charset=US-ASCII\n\n";
print join("\n",@paramnames);
foreach $key (@paramnames)
{
print "Key - $key / Data - ".$cgiinfo->param($key)."\n";
}
print $ENV{'QUERY_STRING'};
HTML:
<HTML>
<HEAD>
<TITLE> Testing page </TITLE>
<BODY>
<H1> GET here </H1>
<FORM name="GET" method="GET" action="http://www.example.com/cgi-bin/what2.cgi?next=W9vmY&sid=8TviP">
<B>Email Address</B>: <input type=text name="email"><BR>
<INPUT TYPE="reset" value=" Clear-Form">*<input type=submit name=Submit value="Send">
</form>
<H1> POST here </H1>
<FORM name="POST" method="POST" action="http://www.example.com/cgi-bin/what2.cgi?next=W9vmY&sid=8TviP">
<B>Email Address</B>: <input type=text name="email"><BR>
<INPUT TYPE="reset" value=" Clear-Form">*<input type=submit name=Submit value="Send">
</form>
</BODY>
</HTML>