如何使用隐含表但传递页面数据 |
|
use strict;
my %input=readInput(); my $username= $input{'username'}; my $password= $input{'password'}; if (($username eq "djl") and ($password eq '12345')){ showWelcom($username,$password); exit 1; } showLogin(); ############################################################################ sub showLogin #7/24/00 3:53PM ############################################################################ { print <<"EOF"; content-type:text/html\n <html> <head> <title>使用隐含表单传输数据</title> </head> <body> <form action="http://127.0.0.1/cgi-bin/hidden.pl" method="post"> <p>请输入用户名:<input type="text" size="20" name="username"></p> <p>请输入密码: <input type="password" size="20" name="password"></p> <input type="submit" value="提交"> </form> </body> </html> EOF } ##showLogin ############################################################################ sub showWelcom #7/24/00 1:05PM ############################################################################ { my($username,$password)=@_; print <<"EOF"; content-type:text/html\n <html> <head> <title>欢迎</title> </head> <body> <p>欢迎你!$username,你有一条秘密信息,请点击“观看”按钮。</p> <form action="http://127.0.0.1/cgi-bin/showmessage.pl" method="post"> <input type="hidden" name="username" value="$username"><input type="hidden" name="password" value="$password"><p><input type="submit" value="观看"> </p> </form> </body> </html> EOF } ##showWelcom ############################################################################ sub readInput() ############################################################################ { my (%field,$in,$name,$value,@pairs); if($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } elsif($ENV{'REQUEST_METHOD'} eq 'GET') { $in=$ENV{'QUERY_STRING'}; } else{ return undef; } $field{'data'}=$in; @pairs = split(/&/,$in); foreach (@pairs) { $_ =~ s/\+/ /g; ($name,$value) = split(/=/,$_); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $field{$name} = $value; } return (%field); } ############################################################################ sub sendCookie #7/24/00 1:21PM ############################################################################ { my($user,$pass)=@_; print <<"EOF"; content-type:text/html set-cookie:username=$user set-cookie:password=$pass <html><body>cookies:<BR> username=$user<BR> password=$pass<br> 已发送 </body></html> EOF } ##sendCookie use strict; my %input=readInput(); my $username= $input{'username'}; my $password= $input{'password'}; if (($username eq "djl") and ($password eq '12345')){ showWelcom($username,$password); exit 1; } showLogin(); ############################################################################ sub showLogin #7/24/00 3:53PM ############################################################################ { print <<"EOF"; content-type:text/html\n <html> <head> <title>使用隐含表单传输数据</title> </head> <body> <form action="http://127.0.0.1/cgi-bin/hidden.pl" method="post"> <p>请输入用户名:<input type="text" size="20" name="username"></p> <p>请输入密码: <input type="password" size="20" name="password"></p> <input type="submit" value="提交"> </form> </body> </html> EOF } ##showLogin ############################################################################ sub showWelcom #7/24/00 1:05PM ############################################################################ { my($username,$password)=@_; print <<"EOF"; content-type:text/html\n <html> <head> <title>欢迎</title> </head> <body> <p>欢迎你!$username,你有一条秘密信息,请点击“观看”按钮。</p> <form action="http://127.0.0.1/cgi-bin/showmessage.pl" method="post"> <input type="hidden" name="username" value="$username"><input type="hidden" name="password" value="$password"><p><input type="submit" value="观看"> </p> </form> </body> </html> EOF } ##showWelcom ############################################################################ sub readInput() ############################################################################ { my (%field,$in,$name,$value,@pairs); if($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } elsif($ENV{'REQUEST_METHOD'} eq 'GET') { $in=$ENV{'QUERY_STRING'}; } else{ return undef; } $field{'data'}=$in; @pairs = split(/&/,$in); foreach (@pairs) { $_ =~ s/\+/ /g; ($name,$value) = split(/=/,$_); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $field{$name} = $value; } return (%field); } ############################################################################ sub sendCookie #7/24/00 1:21PM ############################################################################ { my($user,$pass)=@_; print <<"EOF"; content-type:text/html set-cookie:username=$user set-cookie:password=$pass <html><body>cookies:<BR> username=$user<BR> password=$pass<br> 已发送 </body></html> EOF } ##sendCookie use strict; my %input=readInput(); my $username= $input{'username'}; my $password= $input{'password'}; if (($username eq "djl") and ($password eq '12345')){ showWelcom($username,$password); exit 1; } showLogin(); ############################################################################ sub showLogin #7/24/00 3:53PM ############################################################################ { print <<"EOF"; content-type:text/html\n <html> <head> <title>使用隐含表单传输数据</title> </head> <body> <form action="http://127.0.0.1/cgi-bin/hidden.pl" method="post"> <p>请输入用户名:<input type="text" size="20" name="username"></p> <p>请输入密码: <input type="password" size="20" name="password"></p> <input type="submit" value="提交"> </form> </body> </html> EOF } ##showLogin ############################################################################ sub showWelcom #7/24/00 1:05PM ############################################################################ { my($username,$password)=@_; print <<"EOF"; content-type:text/html\n <html> <head> <title>欢迎</title> </head> <body> <p>欢迎你!$username,你有一条秘密信息,请点击“观看”按钮。</p> <form action="http://127.0.0.1/cgi-bin/showmessage.pl" method="post"> <input type="hidden" name="username" value="$username"><input type="hidden" name="password" value="$password"><p><input type="submit" value="观看"> </p> </form> </body> </html> EOF } ##showWelcom ############################################################################ sub readInput() ############################################################################ { my (%field,$in,$name,$value,@pairs); if($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } elsif($ENV{'REQUEST_METHOD'} eq 'GET') { $in=$ENV{'QUERY_STRING'}; } else{ return undef; } $field{'data'}=$in; @pairs = split(/&/,$in); foreach (@pairs) { $_ =~ s/\+/ /g; ($name,$value) = split(/=/,$_); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $field{$name} = $value; } return (%field); } ############################################################################ sub sendCookie #7/24/00 1:21PM ############################################################################ { my($user,$pass)=@_; print <<"EOF"; content-type:text/html set-cookie:username=$user set-cookie:password=$pass <html><body>cookies:<BR> username=$user<BR> password=$pass<br> 已发送 </body></html> EOF } ##sendCookie use strict; my %input=readInput(); my $username= $input{'username'}; my $password= $input{'password'}; if (($username eq "djl") and ($password eq '12345')){ showWelcom($username,$password); exit 1; } showLogin(); ############################################################################ sub showLogin #7/24/00 3:53PM ############################################################################ { print <<"EOF"; content-type:text/html\n <html> <head> <title>使用隐含表单传输数据</title> </head> <body> <form action="http://127.0.0.1/cgi-bin/hidden.pl" method="post"> <p>请输入用户名:<input type="text" size="20" name="username"></p> <p>请输入密码: <input type="password" size="20" name="password"></p> <input type="submit" value="提交"> </form> </body> </html> EOF } ##showLogin ############################################################################ sub showWelcom #7/24/00 1:05PM ############################################################################ { my($username,$password)=@_; print <<"EOF"; content-type:text/html\n <html> <head> <title>欢迎</title> </head> <body> <p>欢迎你!$username,你有一条秘密信息,请点击“观看”按钮。</p> <form action="http://127.0.0.1/cgi-bin/showmessage.pl" method="post"> <input type="hidden" name="username" value="$username"><input type="hidden" name="password" value="$password"><p><input type="submit" value="观看"> </p> </form> </body> </html> EOF } ##showWelcom ############################################################################ sub readInput() ############################################################################ { my (%field,$in,$name,$value,@pairs); if($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } elsif($ENV{'REQUEST_METHOD'} eq 'GET') { $in=$ENV{'QUERY_STRING'}; } else{ return undef; } $field{'data'}=$in; @pairs = split(/&/,$in); foreach (@pairs) { $_ =~ s/\+/ /g; ($name,$value) = split(/=/,$_); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $field{$name} = $value; } return (%field); } ############################################################################ sub sendCookie #7/24/00 1:21PM ############################################################################ { my($user,$pass)=@_; print <<"EOF"; content-type:text/html set-cookie:username=$user set-cookie:password=$pass <html><body>cookies:<BR> username=$user<BR> password=$pass<br> 已发送 </body></html> EOF } ##sendCookie |