44 lines
1.1 KiB
Perl
44 lines
1.1 KiB
Perl
<HTML>
|
|
<HEAD>
|
|
<TITLE>CGI Form</TITLE>
|
|
<HR>
|
|
<FORM ACTION="index.pl" METHOD=POST>Name: <BR>
|
|
<INPUT TYPE="text" SIZE=50 NAME=Name>Please enter your salary ($####.##): <BR>
|
|
<INPUT TYPE="text" SIZE=30 NAME=Salary><P>Please enter your birth date (mm/dd/yy): <BR>
|
|
<INPUT TYPE="text" SIZE=30 NAME=Birthdate><P>
|
|
<INPUT TYPE=SUBMIT VALUE="Submit Query">
|
|
<INPUT TYPE=RESET VALUE="Reset">
|
|
</FORM>
|
|
</HTML>
|
|
|
|
|
|
File: index.pl
|
|
|
|
#!c:/perl/bin/perl
|
|
print "Content-type: text/html\n\n";
|
|
print <<HTML;
|
|
<html><title>Decoding the Input Data</title>
|
|
<body>
|
|
HTML
|
|
print "Decoding the query string";
|
|
Getting the input
|
|
$inputstring=$ENV{QUERY_STRING}};
|
|
print "<B>Before decoding:</B>";
|
|
print "<P>$inputstring";
|
|
@key_value=split(/&/,$inputstring);
|
|
foreach $pair ( @key_value){
|
|
($key, $value) = split(/=/, $pair);
|
|
$value=~s/%(..)/pack("C", hex($1))/ge;
|
|
$value =~ s/\n/ /g;
|
|
$value =~ s/\r//g;
|
|
$value =~ s/\cM//g;
|
|
$input{$key}=$value ; # Creating a hash
|
|
}
|
|
print "<P><B>After decoding:</B><P>";
|
|
while(($key, $value)=each(%input)){
|
|
print "$key: <I>$value</I><BR>";
|
|
}
|
|
print <<HTML;
|
|
</body>
|
|
</html>
|
|
HTML |