Menu
I would like to make a form that has only two areas of information for the user to fill out. one would be name, the other would be registration ticket number. it sonds simple enough for me until this point too but i would like the form to send me the information to my mail and post only the name of that particular person on the webpage. so when the user comes back in he sees that his name is “on the list” so to speak.
any help with this would be much appreciated thank you in advance.
Regards,
THURO.
[url]www.urvak.com
[CODE]
#!/usr/local/bin/perl
require TripodCGI;
my $CGI = new TripodCGI;
my $number = $CGI->param('number');
my $name = $CGI->param('name');
open(LIST, ">>namelist.txt");
print LIST <<END;
$namer
END
close(LIST);
print <<END;
Content-Type: text/htmlnn
require Mail;
$mail = new Mail;
$mail_template = "mail.txt";
%templateVar = ('webmaster' => '//your email',
'name' => "$name",
'number' => "$number");
$mail->sendMail($mail_template, %templateVar);
print <<END;
Content-Type: text/htmlnn
//here you add an html page for them to be shown after submitting
END
[/CODE]
[CODE]
package TripodCGI;
################
# TripodCGI.pm #
#############################################################################
# TripodCGI is a module to help you deal with CGI input, which is the kind #
# of input your script can get from forms (as well as from specially-coded #
# links). When you have a form submit its information to your script, #
# you can use TripodCGI to grab some or all of the inputs that the form #
# provided, so that you can use them for your own nefarious ends ;) #
# #
# Of the functions below, the only two that you are likely to need to pay #
# attention to are param() and redirect(). param() is the function which #
# lets you grab CGI input. If you specify the name of a particular input #
# that you want to grab, param() will grab the value associated with the #
# input of that name. So if I have a form with a text input box named #
# 'address', and somebody types in '160 Water St.' and hits the submit #
# button, I can assign '160 Water St.' to the variable $form_address within #
# my form with this statement: #
# #
# $form_address = $CGI->param('address'); #
# #
# If you just want to know all of the names of the inputs returned by #
# the form, don't specify an input, and the names of all the inputs will be #
# returned as an array - like this: #
# #
# @all_inputs = $CGI->param(); #
# #
# The other function you might want to use is redirect(). redirect() lets #
# you specify the URL of a page or script that you want to move your #
# visitor to. You could use it like this: #
# #
# $CGI->redirect('http://www.tripod.com'); <- redirects to the Tripod #
# front page #
#############################################################################
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
%data = ();
$self->_initialize();
return $self;
}
sub param {
my($self,$key) = @_;
return keys %data unless $key;
return undef unless defined($data{$key});
my @values = split(" ", $data{$key});
return wantarray ? @values : $values[0];
}
sub redirect {
my($self,$url) = @_;
return "Status: 302 FoundnLocation: $urln" .
"URI: $urlnContent-type: text/htmlnn";
}
sub _initialize {
my $query_string = '';
if ($ENV{REQUEST_METHOD} eq 'POST') {
read(STDIN, $query_string, $ENV{CONTENT_LENGTH});
} else {
$query_string = $ENV{QUERY_STRING};
}
my($key,$val);
for (split(/&/, $query_string)) {
s/+/ /g;
($key,$val) = split(/=/, $_, 2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/rn/n/g;
$val =~ s/r/n/g;
if (defined($data{$key})) {
$data{$key} .= " ";
$data{$key} .= $val;
} else {
$data{$key} = $val;
}
}
}
1;
[/CODE]
[CODE]
To: $webmaster
From: YourWebsite
Subject: New member on list
$name
$number
[/CODE]
and Mail.pm... I know my module is specifically designed for the server. So: does your server come with a mailling module? if so, please post it. Otherwise: I need you to find out how to send a mail file from your server. Such as: what do you name the mail file when saving it to the server so it will be sent? Or is there a different way for the server to send mail?
[/QUOTE]
[CODE]
package Mail;
################
# TripodMail.pm #
#############################################################################
# TripodMail is a module that allows you to send out email messages with
# your scripts. In order to use it you'll have to have a mail template in
# your cgi-bin directory. The mail template will need to look something
# like this:
# To: $email
# From: [email protected]
# Subject: YabbaDabbaDoo!
#
# Hello $name,
# Congratulations! You're user number $number of this mail script!
# You can add other email headers (Reply-To:, Errors-To:, etc), but To:
# and From: are manditory. You can customize your email by adding variables
# wherever you would like to fill something in on the fly.
# The sendMail method requires 2 parameters- the location of the mail
# template file, and a reference to a hash of variables.
# The keys of the varaible hash should correlate with the variables in the
# mail template.
# Example of use:
# require TripodMail;
# $MAIL = new TripodMail;
# $mail_template = "./flintstones_mail.txt";
# %variables = ('email' => '[email protected]',
# 'name' => 'Wilma',
# 'number' => '2');
# $MAIL->sendMail($mail_template, %variables);
# Note: In order to prevent spamming, you will be limited to sending out 240
# mails per day.
###########################################################################
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub sendMail {
# example: $MAIL->sendMail($template_file, %hash_o_variables)
# requires: 1) name of a file that is a template for the mail
# 2) a reference to hash of variables to fill out the template
# does: writes a mail file to member's directory to be mailed later
# by sendmail
# returns: 1 on success, 0 on failure
my ($self, $template_file, $hash_ref) = @_;
my ($message, $key, $time, $file);
# error checking
if ((! $template_file)||(! $hash_ref)){
print STDERR "usage: sendMail(template_file, hash_reference)n";
return 0;
}
if (! -s $template_file){
print STDERR "file does not exist or has a 0 size!n";
return 0;
}
# read in template
open (MESSAGE, "<$template_file") or
die "can't open template file $template for readingn";
undef $/;
$message = <MESSAGE>;
close (MESSAGE);
$/ = "n";
# variable substitution
foreach $key (keys (%{$hash_ref})){
$message =~ s/$$key/$hash_ref->{$key}/eg;
}
# check final template format
if ($message !~ /to:.*w+@w+.w+/i){
print STDERR "To: field missing or invalid recipientn";
return 0;
}
if ($message !~ /from:.*w+@w+.w+/i){
print STDERR "From: field missing or invalid sendern";
return 0;
}
# write template to file
$time = time();
$file = 'mail.'.$time;
open (FILE, ">$file") or
die "can't open file: $file for writingn";
print FILE $message;
close (FILE);
return 1;
}
1;
[/CODE]
[CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0056)http://modamono.com/cp/scripts/formmail-doc/example.html -->
<HTML><HEAD><TITLE>Mailform example</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD>
<BODY>
<FORM name=formmail action=/cgi-bin/formmail/formmail.cgi method=post><INPUT
type=hidden [email protected] name=recipient>
<P><B>Name of Registrant:</B><BR>
<INPUT size=45 name=subject></P><BR>
<P><B>Billing Address:</B><BR>
<INPUT size=45 name=realname>
</P>
<P> </P>
<P><b>City:</b><BR>
<INPUT size=45 name=realname2>
</P>
<P> </P>
<P><b>State:</b><BR>
<select name="select">
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachisetts">Massachisetts</option>
<option value="Michigan">Michigan</option>
<option>Minnesota</option>
</select>
</P>
<BR>
<P><B>Telephone:</B><BR>
<INPUT size=45 name=email></P>
<BR>
<P><B>Comments:</B><BR><TEXTAREA name=body rows=10 wrap=virtual cols=60></TEXTAREA></P><BR>
<P><INPUT type=submit value="Send Email">
<INPUT type=reset value="Reset Form"></P></FORM></BODY></HTML>[/CODE]
[CODE]
#!/usr/local/bin/perl
open(LIST, "<namelist.txt");
my @names = <LIST>;
close(LIST);
my $list="";
for (my $i=0; $i < $names.length; $i++)
{
$list += "<li>"+$names[i]+"</li>";
}
print <<END;
Content-Type: text/htmlnn
//here you add an html page for them to be shown after submitting
//and somewhere in the html page you have...
<ul>
$list
</ul>
//you can use an ordered list if you'd like. then just change the ul tags to ol tags
END
[/CODE]
[CODE]
<ul>
$list
</ul>
[/CODE]
[CODE]
<ol>
$list
</ol>
[/CODE]
[CODE]
Content-Type: text/htmlnn
[/CODE]
[CODE]
END
[/CODE]
[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Drift Circuit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="dcbg.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="778" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="396" colspan="7" valign="top"><img src="dcnews.jpg" width="779" height="397" border="0" align="top" usemap="#Map"></td>
</tr>
<tr>
<td width="28" rowspan="4" valign="top"> </td>
<td width="120" height="454" rowspan="3" valign="top" bgcolor="#CCCCCC"> </td>
<td width="5" rowspan="3" valign="top" bgcolor="#FFFFFF"> <p> </p></td>
<td width="472" height="1" valign="top" bgcolor="#FFFFFF">
<p> </p>
</td>
<td width="1" rowspan="3" valign="top" bgcolor="#FFFFFF"> </td>
<td width="120" rowspan="3" valign="top" bgcolor="#CCCCCC"> </td>
<td width="33" rowspan="4" valign="top"> </td>
</tr>
<tr>
<td width="472" valign="top" background="treadbg.jpg" bgcolor="#FFFFFF"><div align="left"><img src="sep.jpg" width="275" height="5"></div>
<p align="left"><img src="headers/gallery.jpg" width="160" height="48"></p>
<p align="left"><img src="sep.jpg" width="275" height="5"></p>
<form action="/cgi-sys/FormMail.pl" method="post" name="name" id="name">
<font size="2" face="Arial, Helvetica, sans-serif">
<INPUT
type=hidden [email protected] name=recipient>
</font><font face="Arial, Helvetica, sans-serif">
<P><font size="2"><B>Name</B><BR>
<INPUT size=45 name=subject>
</font></P>
<P><font size="2"> <B>Address</B><BR>
<INPUT size=45 name=realname>
</font></P>
<P><font size="2" face="Arial, Helvetica, sans-serif"><b>City:</b><BR>
<INPUT size=45 name=realname2>
</font></P>
<P><font size="2" face="Arial, Helvetica, sans-serif"><b>State:</b><BR>
<select name="select">
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachisetts">Massachisetts</option>
<option value="Michigan">Michigan</option>
<option>Minnesota</option>
</select>
</font></P>
<P><font size="2"><strong>Zip:</strong><BR>
<INPUT size=15 name=email>
</font></P>
<P><font size="2"><strong>E-mail:</strong><BR>
<INPUT size=45 name=email2>
</font></P>
<P><font size="2" face="Arial, Helvetica, sans-serif"><b>Year Make &
Model of Vehicle:</b><BR>
<INPUT size=45 name=subject2>
</font></P>
<P><font size="2" face="Arial, Helvetica, sans-serif">
<INPUT name="submit" type=submit value="Send Email">
<INPUT name="reset" type=reset value="Reset Form">
</font></P>
</font>
</form>
<p align="left"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif"><img src="sep.jpg" width="275" height="5"></font></p>
<p align="right"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif"><img src="dcls.jpg" width="100" height="35"></font></p>
</td>
</tr>
<tr>
<td height="1" valign="top" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="10" colspan="5" valign="top" bgcolor="#999999">
<div align="center"><font color="#999999">www.upshotstudios.com</font></div></td>
</tr>
</table>
<map name="Map">
<area shape="circle" coords="347,339,15" href="about.htm" target="_self">
</map>
</body>
</html>
[/code]
[CODE]#!/usr/local/bin/perl
open(LIST, "<namelist.txt");
my @names = LIST>;
close(LIST);
my $list="";
for (my $i=0; $i < $names.length; $i++)
{
$list += "<li>"+$names[i]+"</li>";
}
print <<END;
Content-Type: text/htmlnn
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Drift Circuit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="dcbg.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="778" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="396" colspan="7" valign="top"><img src="dcnews.jpg" width="779" height="397" border="0" align="top" usemap="#Map"></td>
</tr>
<tr>
<td width="28" rowspan="4" valign="top"> </td>
<td width="120" height="454" rowspan="3" valign="top" bgcolor="#CCCCCC"> </td>
<td width="5" rowspan="3" valign="top" bgcolor="#FFFFFF"> <p> </p></td>
<td width="472" height="1" valign="top" bgcolor="#FFFFFF">
<p> </p>
</td>
<td width="1" rowspan="3" valign="top" bgcolor="#FFFFFF"> </td>
<td width="120" rowspan="3" valign="top" bgcolor="#CCCCCC"> </td>
<td width="33" rowspan="4" valign="top"> </td>
</tr>
<tr>
<td width="472" valign="top" background="treadbg.jpg" bgcolor="#FFFFFF"><div align="left"><img src="sep.jpg" width="275" height="5"></div>
<p align="left"><img src="headers/gallery.jpg" width="160" height="48"></p>
<p align="left"><img src="sep.jpg" width="275" height="5"></p>
<p align="left"> </p>
<ol>
$list
</ol>
<p align="left"> </p>
<p align="left"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif"><img src="sep.jpg" width="275" height="5"></font></p>
<p align="right"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif"><img src="dcls.jpg" width="100" height="35"></font></p>
</td>
</tr>
<tr>
<td height="1" valign="top" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="10" colspan="5" valign="top" bgcolor="#999999">
<div align="center"><font color="#999999">www.upshotstudios.com</font></div></td>
</tr>
</table>
<map name="Map">
<area shape="circle" coords="347,339,15" href="about.htm" target="_self">
</map>
</body>
</html>
[/CODE]
[CODE]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">[/CODE]
[CODE]
<table width="778" height="100[B]%[/B]" border="0" align="center" cellpadding="0" cellspacing="0">[/CODE]
[CODE]
<table width="778" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">[/CODE]
0.1.9 — BETA 6.16