Solved

can't hand over parameters from html to perl!

Posted on 2000-04-26
3
175 Views
Last Modified: 2006-11-17
Hi!

I have a HTML-page with a simple link to mp3.pl. It works fine. But how to hand over parameters? I tried:
<a href="mp3.pl?key1=value1&key2=value2> and so on.
I guess thats the post-methode(?). So I read in the parameters with:
read(STDIN, $Income, $ENV{'CONTENT_LENGTH'});

But the mp3.pl don't get ANY parameters!

It works with forms (and submit-buttons), so, what do I wrong????

MfG Panther
0
Comment
Question by:pantherchen
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 100 total points
ID: 2751444
"<a href="mp3.pl?key1=value1&key2=value2>"

The method you are using above is the GET method.

Here is a brief explanation of the difference between GET and POST methods.

CGI scripts are called in two main ways.
The HTTP GET method is used in document retrievals where an identical request will produce an identical result, such as a dictionary lookup. A GET stores form data in the URL. This means it can be conveniently bookmarked for canned requests, but has limitations on the total size of the data requested.

The HTTP POST method sends form data separate from the request.
It has no such size limitations, but cannot be bookmarked. Forms that update information on the server, like mailing in feedback or modifying a database entry, should use POST. Client browsers and intervening proxies are free to cache and refresh the results of GET requests behind your back, but they may not cache POST requests. GET is only safe for short read-only
requests, whereas POST is safe for forms of any size, as well as for updates and feedback responses.

===========================================

Here is the mp3.pl script that will help you read incoming variables from your HTML form.

i am assuming that you have already have the CGI.pm PERL module installed on your system.

This program will read the parameters that you are sending, either via a POST method or a GET method and display the values of those variables on your screen/browser.

#!/usr/local/bin/perl

use CGI;

$query=new CGI;

$key1=$query->param('key1');
$key2=$query->param('key2');

print "Content-type: text/html\n\n";

print $key1,"<br>\n";
print $key2,"<br>\n";
=============================

Hope that helps
0
 
LVL 1

Author Comment

by:pantherchen
ID: 2751534
Yeah, it works fine! Thank you very much (I've already spent about 4 hours by solving it by myself)!!!!!
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2751578
Glad to know that your problem was solved. :-)

Rgds
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question