Friday, August 5, 2016

HTML Form in Perl CGI

A simple program that I wrote in Perl CGI to show how to use HTML FORM to capture the user input and display the result in the same page. The code is very easy to understand and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

#!"C:\xampp\perl\bin\perl.exe"
use strict;
use warnings;
use CGI qw(:all);

my $cgi = new CGI;
my $this_url = $cgi->url(); 
my $first = $cgi->param('first_name');
my $last = $cgi->param('last_name');
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Perl Same Page Display</title></head>
<style>
  body {
   font-family: arial;
   font-size: 18px;
   font-weight: bold;
 };
</style>
<body>
<FORM action="$this_url" method="POST">
<font color='green'>
What is your first name <input type="text" name="first_name" value='$first'>  <br>
What is you last name  <input type="text" name="last_name" value='$last'>
<br><br>
<input type="submit" value="Ok">
</FORM>
<p>Hello $first $last How are you today?</p> </font>
</body>
EndOfHTML



No comments:

Post a Comment