damainman77
07-15-2003, 08:51 AM
I have written a CGI script (in Perl) that prints a big block of html text (a web form), gives a confirmation message to the user. and now I want the script to send me an email with all of the values put in by the user. Here is the beggining of the script, that is used to produce the confirmation message, as well as to define $recipient as my email address and the location of sendmail.
#!/usr/bin/perl -w
use CGI ':standard';
print header;
$mailprog = '/usr/sbin/sendmail';
$recipient = 'myemail@somewhere.com';
print start_html('Code 974 New User Account Application Form');
if (param()) {
print '<body bgcolor="#FFDAB9"><a href="http://hsb.gsfc.nasa.gov"><img SRC="gif/hydro.sm.gif" align="left" valign="top"></a><a href="http://www.nasa.gov"><img SRC="gif/NASAlogo.gif" valign="top" align="right"></a></align>
<center><h1>Thank You</h1>';
print "<br><i><h2>Your information has been succesfully submitted</h2></i><br><hr><br><br></center>";
my @params = param();
foreach my $parameter(@params) {
print "<b>", $parameter,"</b>", " - ", param($parameter),"<br>";
}
print '<br><center><font size="+2">To resubmit, please click <a href="http://lshp.gsfc.nasa.gov/status/userapp.cgi">here</a></font></center><br><br>';
print '<hr color="" size=5 width=90%>
--------------------------------------------------------------------
I'm not going to actually paste the entire source for the form in this message, because it is unneccesary, but I will give you the names of all the fields. FirstName, LastName, GSFCIDNumber, PhoneNumber, FaxNumber, Location, email, IP_HostName, Title, Leader, SGI, DECAlpha, PCs, UserName, AlternateUserName, Comments.
---------------------------------------------------------------------
My boss suggested using something like form.FirstName.value to show the value for FirstName, but I'm not sure how this works. Can someone tell me, possibly based on the opening CGI that I provided how I can put in a script to send me an email with form results at the end of the file? Here is what I'm starting with.........
---------------------------------------------------------------------
open (MAIL, "|$mailprog -t 'sambrin' ") || die "cannot open $mailprog!\n";
print MAIL <<EOF;
#someone please tell me what to put here....
Close (MAIL);
#!/usr/bin/perl -w
use CGI ':standard';
print header;
$mailprog = '/usr/sbin/sendmail';
$recipient = 'myemail@somewhere.com';
print start_html('Code 974 New User Account Application Form');
if (param()) {
print '<body bgcolor="#FFDAB9"><a href="http://hsb.gsfc.nasa.gov"><img SRC="gif/hydro.sm.gif" align="left" valign="top"></a><a href="http://www.nasa.gov"><img SRC="gif/NASAlogo.gif" valign="top" align="right"></a></align>
<center><h1>Thank You</h1>';
print "<br><i><h2>Your information has been succesfully submitted</h2></i><br><hr><br><br></center>";
my @params = param();
foreach my $parameter(@params) {
print "<b>", $parameter,"</b>", " - ", param($parameter),"<br>";
}
print '<br><center><font size="+2">To resubmit, please click <a href="http://lshp.gsfc.nasa.gov/status/userapp.cgi">here</a></font></center><br><br>';
print '<hr color="" size=5 width=90%>
--------------------------------------------------------------------
I'm not going to actually paste the entire source for the form in this message, because it is unneccesary, but I will give you the names of all the fields. FirstName, LastName, GSFCIDNumber, PhoneNumber, FaxNumber, Location, email, IP_HostName, Title, Leader, SGI, DECAlpha, PCs, UserName, AlternateUserName, Comments.
---------------------------------------------------------------------
My boss suggested using something like form.FirstName.value to show the value for FirstName, but I'm not sure how this works. Can someone tell me, possibly based on the opening CGI that I provided how I can put in a script to send me an email with form results at the end of the file? Here is what I'm starting with.........
---------------------------------------------------------------------
open (MAIL, "|$mailprog -t 'sambrin' ") || die "cannot open $mailprog!\n";
print MAIL <<EOF;
#someone please tell me what to put here....
Close (MAIL);