#!./perl

require "scripts/cgi-lib.pl";

&print_HTTP_header;
&print_head;
&process_form;
&print_body;
&print_footer;
&print_tail;

#
# This subroutine emits the required HTTP header 
# for the "results" page seen by the user
#
sub print_HTTP_header {

print "HTTP/1.0 200 OK\n";
print "Content-type: text/html\n";

}

#
# This subroutine emits the HEAD section including
# the page title, then opens the BODY section
# and emits a level-one heading.
#
sub print_head {

print "\n";
print "<HTML>\n";
print "<HEAD>";
print "<TITLE>";
print "PC Magazine HTML Form and Script Demo Results";
print "</TITLE>";
print "</HEAD>";
print "<BODY>";
print "<H1> PC Magazine HTML Form and Script Demo Results</H1>";

}

#
# This subroutine formats the data entered by the
# user into the "$message" variable.
#
sub process_form {

# First we call cgi-lib.pl routine to parse the
# form data string into the component variable
# names and their values
&ReadParse();

# Now we format some captions and the variable
# values into a single long string for convenience.
# We could write this result string to a file
# or email it, but for this demonstration we
# will just display it back to the user.
$message = <<END;

Name:                $in{name}
Company:             $in{company}
Street:              $in{street}
City, State, Zip:    $in{city}
Email:               $in{email}
Phone:               $in{phone}
Fax:                 $in{fax}

Computer Experience: $in{experience}

END
  
}

#
# This subroutine displays the formatted data 
# from the data entry form for review by the user.
#
sub print_body {

print<<END;

Thank you for filling out our form. Here is a summary
for your records of the information as we received it.
You can click the PRINT button in your browser to generate 
a hard copy of this transaction.<P>
<HR>
<P>

<PRE>
$message
</PRE>
<P>

END

}

#
# This subroutine emits the page footer as seen 
# by the user.
#
sub print_footer {

print <<END;

<P>
<HR>
<ADDRESS>
Created 6-15-96 / Last modified 6-15-96<BR>
PC Magazine Power Programming / 
<A HREF="mailto:duncan@cerf.net">duncan@cerf.net</A>
</ADDRESS>

END

}

#
# This routine closes the <BODY> and <HTML> sections
# of the HTML output stream.
#
sub print_tail {

print "</BODY>";
print "</HTML>\n";

}

