<html>
<head>
<title>个人信息</title>
</head>
<body>
<h2 Align="center">我的个人信息</h2>
<FORM METHOD=GET ACTION="http://localhost:1087/cgi-bin/geteachatt.pl">
<p>姓名:<input name="name" size=17>
性别:<input name="sex" type=RADIO value="male" CHECKED>男
<input name="sex" type=RADIO value="female">女
<p>家庭所在地:
<select name="city" SIZE="1">
<option selected>北京</option>
<option selected>上海</option>
<option selected>成都</option>
<option selected>其他城市</option>
</select>住址:<input name="address" size=25>
<p align="left">
<input type=submit value="发送">
<input type=submit value="重置">
<p>
</FORM>
</body>
</html>
在geteachatt.pl中写入
#!d:/perl/bin/perl
print "Content-type:text/html","\n\n";
print "<HTML>","\n";
print "<HEAD>","\n";
print "<TITLE>测试Get方式下的表单数据传输方法</TITLE>","\n";
print "</HEAD>","\n";
print "<BODY>","\n";
print "<H2>从URL获取的信息</H2>","\n";
$QuerystringFromEnv=$ENV{QUERY_STRING};
@NameAndValuelists=split(/&/,$QuerystringFromEnv);
foreach $NameAndValue(@NameAndValuelists) {
($Name,$Value)=split(/=/,$NameAndValue);
$Name=~tr/+//;
$Value=~s/%([\dA-Fa-f][\dA-Fa-f])/pack("c",hex($1))/eg;
print "属性名=$Name,属性值=$Value","<BR> \n";
}
print "</BODY>","\n";
print "</HTML>","\n";
打开浏览器,输入test1.html
file//D:\Program Files\Apache2.2\cgi-bin\test1.html//D:\Program Files\Apache2.2\cgi-bin\test1.html
填入姓名,性别,住址等信息,然后单击发送按钮,显示如下