programming-examples/perl/CGI/A Form-Based Example.pl

21 lines
611 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
<HTML><HEAD>
<TITLE>A Simple Form-Based Example</TITLE>
</HEAD>
<FORM METHOD=GET ACTION="index.pl">
<H1>Please enter your name:</H1>
<P>First name: <INPUT NAME="first" TYPE=TEXT></P>
<P>Last name: <INPUT NAME="last" TYPE=TEXT></P>
<P><INPUT NAME="OK" TYPE=SUBMIT></P>
</FORM>
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $cgi=new CGI; #read in parameters
print $cgi->header(); #print a header
print $cgi->start_html("Welcome"); #generate HTML document start
print "<h1>Welcome, ",$cgi->param('first')," ",$cgi->param('last'),"</h1>";
print $cgi->end_html(); #finish HTML document