title: PHP: handling a POST request sent from Perl
body: <p>I'm new to PHP and I seem to be doing something wrong. On one hand, I have a Perl script that looks like this:</p>
  
  <pre><code>use LWP::UserAgent;
  
  my $browser = LWP::UserAgent-&gt;new;
  my $url = 'https://url/index.php';
  
  my $response = $browser-&gt;post($url, [
          "command" =&gt; "test",
              "data" =&gt; "123"
           ]);
  
  die "Error getting $url" unless $response-&gt;is_success;
  
  print $response-&gt;content;
  </code></pre>
  
  <p>On the server, the index.php file looks like this:</p>
  
  <pre><code>&lt;?php
  
  if($_SERVER['REQUEST_METHOD'] == "POST"){ 
      echo "Hello!\n";
  }else {
      echo "Error\n";
  }
  ?&gt;
  </code></pre>
  
  <p>And... that's it. If I try to execute the Perl script, however, <strong>it prints the whole index.php file, instead of Hello! or that other error message</strong>. I guess it makes sense that I'm requesting a file and that's what it's printing, however I'm quite confused about what it is I'm doing wrong. I've been looking around for examples for a while but I've found nothing so far that could point me in the right direction.</p>