Coding 101

Jul 24th 2014

Coding 101 27

Perl: Reading POST Form Actions

Use POST with CGI in Perl.

Although the show is no longer in production, you can enjoy episodes from the TWiT Archives.
Category: Help & How To

The code for today's show is available at our: GitHub

Ivory Tower

Let's play with some POST! Last week we used the "GET" method within the HTML "FORM" tag to get information from the browser.

<FORM METHOD=GET ACTION="../cgi-bin/animal_name.pl">
<h2>Would you care to name this creature?</h2><br>
<INPUT NAME="NameOfCreature"><br>
<INPUT TYPE=SUBMIT>
</FORM>

  • If we type "My Dog" into the field and click Submit, it will create a URL that calls the script "animal_name.pl" and passes it the value "My+Dog"
  • The resulting URL would read: cgi-bin/bunny.pl?NameOfCreature=My+Dog Now we're going to use "POST"
  • While "GET" was fine for little pieces of data entry from the user, "POST" is the preferred methods for sending longer strings and combinations of HTML FORM data.
    • Unlike GET, POST requests have no restriction on data length. POST is NOT secure, but it DOES have a few security advantages to GET
  • GET requests remain in the browser history, CAN be cached and can be bookmarked.
  • POST requests are NOT retained the browser history, nor are they cacheable or bookmarkable.

Get in Touch With Us!

Bandwidth for Coding 101 is provided by CacheFly.

Links