Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>A NEW CGI PAGE</TITLE></HEAD>\n";
print "<BODY><P>Hello World</P></BODY></HTML>";
<a href="http://www.someserver.com/cgi-bin/simple.cgi">simple CGI</a>
<FORM ACTION="http://www.server.com/cgi-bin/code.cgi" METHOD="POST">
<HTML>
<HEAD><TITLE>Most Basic CGI Input Page</TITLE></HEAD>
<BODY>
<FORM ACTION="/cgi-bin/simple.cgi" METHOD="POST">
<P>email, please:
<INPUT TYPE="TEXT" WIDTH="25" NAME="Email_Address">
</P></FORM></BODY></HTML>
#!/usr/local/bin/perl
#
%FORM = &cgidecode();
$email = $FORM{Email_Address};
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Catching an email</TITLE></HEAD>\n";
print "<BODY><P>Address is: $email.</P></BODY></HTML>";
sub cgidecode
{
local(%vars, $val, $key, $last, $buffer, $pair, @pairs);
# Checking the form method (GET or POST) used
# in the HTML code. POST method sends data to
# standard input, but GET adds it to the URL
# and stores it in QUERY_STRING.
if ($ENV{'REQUEST_METHOD'} eq "POST")
{ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
else
{ $buffer = $ENV{'QUERY_STRING'}; }
# Splitting up the data fields and store in array @pairs,
# they are seperated with &
@pairs = split(/&/, $buffer);
# Splitting the variable names and the values and storing
# them in the assoc. array %vars
foreach $pair (@pairs)
{
($key, $val) = split(/=/, $pair);
$val =~ s/\+/ /g;
$val =~ s/%(..)/pack("C",hex($1))/eg;
if ($key eq $last) {$vars{$key} .= " ".$val; }
else { $vars{$key} = $val; }
$last = $key;
}
return(%vars);
}
#!/usr/local/bin/perl
use CGI;
# instantiate a new CGI object. Call it $q.
$q = new CGI;
print $q->header;
print $q->start_html;
# retreive the Email_Address parameter submitted in the HTML
$email = $q->param('Email_Address');
# check to see if it looks like an email.
unless ($email =~ /.*@.*\.\w+/)
{ &killme("Not a valid email address"); }
print "<P>Email is $email</P>\n";
print $q->end_html;
sub killme {
print "<P>$_[0]</P>";
print $q->end_html;
die;
}
#!/usr/local/bin/perl
use CGI;
$cgi = new CGI;
$this_prog = $cgi->self_url;
print $cgi->header,$cgi->start_html(-title=>"A Simple CGI Input Page");
my $email = $cgi->param('email');
if ($email)
{
# check to see if it looks like an email.
unless ($email =~ /.*@.*\.\w+/)
{ &killme("Not a valid email address"); }
print "<P>Email is $email</P>\n";
print $q->end_html;
}
else
{ # no email submitted, we must need to send the input page.
print $cgi->center,
$cgi->h3($header),
$cgi->start_form(-method=>'POST', -action=>"$this_prog"),
"Your email address: ",
$cgi->textfield(-name=>'email',
-size=>'25',
-maxlength=>'40'),
' ',$cgi->submit(-name=>'Submit', -value=>'submit'),
$cgi->endform,"</center>";
}
sub killme
{
print "<P>$_[0]</P>";
print $q->end_html;
die;
}