-4

login.html

 <form method="POST" action="login.php">
 <input type="text" name="username">
 <input type="password" name="password">
 <button class="_sdf3">Login</button>
 </form>

login.pl

 #!/usr/bin/perl
 use LWP::UserAgent;
 my $username = "admin";
 my $password = "pass2321";
 my $url = "http://127.0.0.1/login.html";
 my $ou = new LWP::UserAgent;
 my $req = $ou->post($url,{ username => $username , password => $password , });
 my $code = $req->code;
 if ("$code" eq "302"){
 print "Username And Password OK";
 }else{
 print "Username And Password BAD";
 }

When I run login.pl i will see Username And Password BAD but the data is right!!

I want to fix this problem while using <button class="_sdf3">Login</button> in login.html

ysth
  • 96,171
  • 6
  • 121
  • 214
  • 1
    Always include `use strict; use warnings 'all';` at the top of your Perl scripts. LWP::UserAgent doesn't have a `code` method, so `$ou->code` doesn't make sense. You meant `$req->code`, which calls the `code` method on your [HTTP::Response](https://metacpan.org/pod/HTTP::Response) object. – ThisSuitIsBlackNot Apr 18 '16 at 15:13
  • 3
    ...but I'm guessing this isn't the the code you're actually using, since what you've shown would die with the error `Can't locate object method "code" via package "LWP::UserAgent"` before ever reaching the `else` block. – ThisSuitIsBlackNot Apr 18 '16 at 15:24
  • @toolic Thanks my bro now it is working , but i want to login with https://www.instagram.com/accounts/login/ – Ghadeer R. Majeed Apr 18 '16 at 15:28
  • can you write a simple script to login with https://www.instagram.com/accounts/login/ – Ghadeer R. Majeed Apr 18 '16 at 15:29
  • 2
    @Programmer That's not how [so] works. I would recommend taking a [tour] and reading [ask] so that you know what the expectations are. – Matt Jacob Apr 18 '16 at 16:48

1 Answers1

0

You are posting to login.html but you should be posting to login.php.

ysth
  • 96,171
  • 6
  • 121
  • 214