
Steerpike
Deleted
Apr 3, 2000, 1:48 PM
Post #1 of 1
(1666 views)
|
POSTing with LWP
|
Can't Post
|
|
Firstly, thanks for all previous help (thanks japhy) Now then...I am attempting to write a program that sends data to a perl script on the web via the POST method and reads the resulting HTML file, but I am having trouble doing so. I shall illustrate my problem using the page at http://www.ittc.ukans.edu/~paden/Reference/Encode/form/post.html simply because it is a script which uses the POST method (and which I can' manage to access with a script). The form at this page has the HTML: <FORM action="http://www.ittc.ukans.edu/~paden/cgi-bin/Encode/post" method=POST> <table> <tr> <td>Name:</td> <td><input name="Name" size=60></td> </tr> <tr> <td>Password:</td> <td><input name="Password" type="password" size=60></td> </tr> </table> <input type="reset" value="Reset fields to old values"><br> <input type="submit" value="Click Here to Send to Server"><br> </form> I have the following script, which as far as I can see should print the HTML of the resulting page, however I instead receive an error, what can be wrong? use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("MyAgent/0.1 " . $ua->agent); my $req = new HTTP::Request POST => 'http://www.ittc.ukans.edu/~paden/cgi-bin/Encode/post'; $req->content_type('application/x-www-form-urlencoded'); $req->content('Name=name&Password=password'); my $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { print "There was an error"; } What am I doing wrong that the error is always displayed? Any thanks shall be much appreciated
|