#!/usr/local/bin/perl

require "cgi-lib.pl";

# Flow control begins here
$message_body = undef;
$error = 0;

# Load the input variables
&ReadParse( *input );

# Print the HTTP header
print &PrintHeader;

# Set up the message body
$message_body .= "Name:        $input{'name'}\n" if( "$input{'name'}" ne undef );
$message_body .= "Email:       $input{'email'}\n" if( "$input{'email'}" ne undef );
$message_body .= "Comments:\n$input{'comments'}\n";

# Print the top of the page
print "<HTML><HEAD><TITLE>Your title here</TITLE></HEAD><BODY>\n";

# Print the body of the page
if( "$input{'comments'}" eq undef )
{
  print "<P>You have not entered a comment.</P>";
  print "<P>Please press the back button on your browser and complete ";
  print "the form.</P>";
  $error = 1;
}
else
{
  # This could be bad!!!
  print "<P><B><FONT SIZE=\"+1\">Thanks $input{'name'}.</FONT></B></P>\n";
}


# Print the bottom of the page
print "</BODY></HTML>\n";

if( ! $error )
{
open( MAIL, "|/usr/lib/sendmail -t -n" );
print MAIL <<EndOfMessage
From: mailto form
To: userid\@host.com
Subject: mailto form

$message_body
EndOfMessage
;
exit;
}
