- 论坛徽章:
- 0
|
我作了一个测试文件 test.php
<?php
if($_POST['submit'])
{
$user = trim($_POST['username']);
if(!empty($user))
{
echo "Right!";
exit;
}else{
echo "Wrong";
exit;
}
}
?>
<html>
<title>test </title>
<meta http-equiv="content-type" content="text/html; charset=GB2312">
<body>
<center>
<form method=POST action=/test.php>
<table>
<tr>
<td>姓名:</td><td><input type=text name=username></td>
</tr>
</table>
<input type=submit name=submit value=" 提交 ">
</form>
</center>
</body>
</html>
之后在本机用写了一个perl文件(test.pl),模拟提交的,代码如下:
#!/usr/bin/perl
use strict;
use LWP;
use URI::Escape;
use HTTP::Request::Common;
use constant RFC_SEARCH => 'http://10.3.1.107/test.php';
use constant RFC_REFERER => 'http://10.3.1.107/test.php';
my $ua = LWP::UserAgent->new;
my $search_terms = "@ARGV";
my $request = POST ( RFC_SEARCH,
Content => [ username => $search_terms ],
Referer => RFC_REFERER
);
my $response = $ua->request($request);
die $response->message unless $response->is_success;
my $content = $response->content;
print $content;
我运行 test.pl ddd
问题是,打印出来的$content之后,既不是Right,也不是Wrong,而是HTML源代码。请问什么原因???
十分感谢~~ |
|