Html Forms
Using perl, it is very easy to make a webform (i.e.,
to request information from a user, and return a web page
based on the information the user supplies).
Click here
for an example of a webform.
Here is the html code to create the form
in the example linked to above:
<form method="post" action="emailaliasform.cgi"><br>
Your math.unl.edu username: <textarea rows=1 cols=20 name="text">jdoe</textarea><p>
<input type="submit" value="Submit Form">
</form>
The file "emailaliasform.cgi" collects the user input
generated by the form, and returns to the server
an html response. The file "emailaliasform.cgi" must have execute permissions
(say 755) that allow the webserver to run it.
Here is the important part of what is in the file
"emailaliasform.cgi". In this example, the file is a
perl program, but it could be written in c (but that would entail
some changes to the example code below). Additional perl commands can be included to make
this cgi program more functional; as it stands it simply echos
whatever the user inputs. (The link between the form above and
the cgi below is that the name of the text entry field is "text".
This is actually a variable whose value is whatever the user enters
into the text area. The value of the variable "text" is assigned
by the cgi to the perl variable $userinput.)
#!/usr/bin/perl -w
use CGI qw(param);
print "Content-type: text/html\n\n";
print "<html><head><title>Echo</title></head><body bgcolor=white>\n";
my $userinput = param("text");
print "Here is the text you entered: $userinput<br>\n";
print "</body></html>\n";