Forum Moderators: open
in the form that calls the cgi script, there are a couple of methods of transferring the data. The most commonly used are GET and POST. With GET, the data contained in the form is encoded and made part of the URL that calls the cgi script. With, POST, the data is encoded differently and not included in the URL. You want to use the POST method. Here's an example:
<form name="yourform" action="cgiprocessingscript.cgi" method="POST">
The cgi script may need some modifications to decode the data... here is the routine I use in my scripts:
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $input, $ENV{"CONTENT_LENGTH"});
@holder = split(/&/, $input);
foreach $pair (@holder) {
($name, $value) = split(/=/, $pair, 2);
$value =~ s/\+/ /g;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\r\n/\n/g;
$value =~ s/\r/\n/g;
$name =~ s/\+/ /g;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ s/\r\n/\n/g;
$name =~ s/\r/\n/g;
$fields{$name}=$value;
}
}
You end up with a hash (associative array) that contains the data.
For example, if you have form inputs including "name", "email", and "telephone", you would access these in your cgi script with the following variables:
$fields{'name'}
$fields{'email'}
$fields{'telephone'}