#!/usr/local/bin/perl

#cgi-lib contains functions to manipulate the data contained in html forms
require "cgi-lib";

#The readparse function (from cgi-lib) will create an associative array
#containing the data from the html form.
#Each element of the array will have the same name as the html form item
&ReadParse;

#Generate http header
print "Content-type:text/html\n\n";

#Generate HTML code for AmigaSoc header
#Normally the perl print statement is of the form
#print "stuff_to_print";
#however as we have quotes ("") within our Stuff_to_print we have to
#use alternative quite characters. These are defined with the qq statement
#normal choices include the curly braces {} or the pipe symbol ||
print qq{<body background="../images/paletile.gif">};
print qq{<center><img src="../images/logo.gif"></center><br><br>};
#The following line is a "normal" perl print statement as it contains no ""'s
print "<strong>$in{Name}</strong>, thank you for you comments. We will look at them soon.<br>";
print qq{<br><br><img src="../images/amigasocsig.gif"><br><br>};

#print the end of html tags
print "</body></html>";

#Email the information to webmaster@uk.amigasoc.org
#You should change this address to your_login@your_machinename.your_domainname
open(MAIL,"|mail webmaster\@uk.amigasoc.org");
print MAIL "Subject: Feedback Form\n";

#Loop through the array containing the form data and print each element 
#on a new line. 
foreach $i (keys(%in))
{
	print MAIL "$i = $in{$i}\n";
}
close (MAIL);
