>Q1. If I click on a link to go to another HTML page say name.html, I lose
>the "hop=some_data" part. How do I make the "hop=some_data" go with the
>"name.html" with the <a> tag from an HTML document ? Is this possible or a
>script can do this only ?

there are a couple ways -
one way is to add the "hop=some_data" to the href itself, IF it is a static
string...  ie:   <a href="http://www.domain.com/name.html?hop=some_data";>
otherwise, you can implement a simple CGI/Perl script to generate the
index page from a template...


>Q2. The order page calls a Perl script say "orderpage.pl", I want the
>script to capture the "hop=some_data". I got the script to print the whole
>%ENV, and I see no "HTTP_REFERER". I thought "HTTP_REFERER" would show the
>url that called "orderpage.pl" with the "hop=some_data" . But if I cannot
>see "HTTP_REFERER", then how do I get the script to capture the
>"hop=some_data" ?

The ENV variable you are looking for is definitely the QUERY_STRING...
or use STDIN to retrieve POST data...

If you are using perl (looks like you are using a hash there - %ENV) then
you can
either use the CGI module to retrieve the query strings, in which case you
don't
have to worry about that at all, or you can do something like this -


my %formData;

read STDIN, $_, $ENV{'CONTENT_LENGTH'};  #Read in STDIN to default
variable...
%formData = split/&|=/;                  #Place separate keys/values into
'formData' hash, split by '&' and '='
if (!%formData)                              #- If we didn't get anything
from POST method,
{
   $_ = $ENV{'QUERY_STRING'};                #  try retrieving it from
QUERY_STRING (GET method)
   %formData = split/&|=/;                   #  and split like before.
}


Then to access the data, you would go:
my $hop = $formData{'hop'};

This is a quick hack - CGI module is much better & more efficient
 eg. what happens when you get a number of values from <select multiple> in
this code?


-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to