Demo
<html><head><title>First name Example</title></head>
<body>
First Name Form
<form name = "dataForm" method = "POST" action =
"http://homepages.uc.edu/cgi-bin/cgiwrap/jonesbr/firstparse.pl">
Enter your first name:
<input type="text" name="firstName">
<input type="submit">
</form>
</body>
</html>
#!/usr/local/bin/perl
# Use the CGI.pm library
use CGI;
# Make a new CGI object.
$query = new CGI;
# Write out the content-type header followed by a blank
line.
print $query->header;
# Write the HEAD section, including the title.
print $query->start_html("Welcome");
# Write a welcome message.
print "<H3>Welcome ";
print $query->param('firstName');
print "!";
# End the HTML.
print $query->end_html;
-
It's a good idea to copy-paste this, either form this slide or from the
examples on your account. No need to write it from scratch.
-
HTML generated by CGI.pm
-
Don't forget to chmod if necessary!
More on CGI.pm
Home
Updated Source:
firstparse.pl
#!/usr/local/bin/perl
# Use the CGI.pm library
use CGI;
# Make a new CGI object.
$query = new CGI;
# Write out the content-type header followed by a blank line.
print $query->header;
# Write the HEAD section, including the title.
print $query->start_html("Welcome");
# Write a welcome message.
print "
Welcome ";
$firstName = $query->param('firstName');
print $firstName;
print "!";
print "
Click
here to proceed.";
print "
";
# End the form.
print $query->end_html;
firstparse2.pl
#!/usr/local/bin/perl
# Use the CGI.pm library
use CGI;
# Make a new CGI object.
$query = new CGI;
# Write out the content-type header followed by a blank line.
print $query->header;
# Write the HEAD section, including the title.
print $query->start_html("Welcome");
# Write a welcome message.
print "Goodbye ";
$firstName = $query->param('firstName');
print $firstName;
print "!";
print "
Click
here to proceed.";
print "
";
# End the form.
print $query->end_html;