programming-examples/perl/CGI/Demostrates POST method with HTML form.pl
2019-11-15 12:59:38 +01:00

25 lines
603 B
Perl

# Name this Perl script as test.pl
use warnings;
use strict;
use CGI qw( :standard );
our ( $data, $name, $value );
read( STDIN, $data, $ENV{ 'CONTENT_LENGTH' } );
( $name, $value ) = split( '=', $data );
print header(), start_html( 'Using POST with forms' );
print p( 'Enter one of your favorite words here: ' );
print '<form method = "POST" action = "test.pl">';
print '<input type = "text" name = "word">';
print '<input type = "submit" value = "Submit word">';
print '</form>';
if ( $name eq 'word' ) {
print p( 'Your word is: ', b( $value ) );
}
print end_html();