Help - Search - Member List - Calendar
Full Version: Form and e-mail question
WorkTheWeb Forums > Webmaster Resources > Webmaster - General Help
Support our Sponsors!
Serious_Practitioner
Good day, and thank you in advance for your help.

I would like for visitors to my site to be able to request that a document
be e-mailed to them. At the present time, I allow people to print the page
containing the document - it's time to stop that.

Ideally, someone would open a page and see a form where he/she could order
the document. After entering first and last names, and an e-mail address,
the act of submitting the form would put the data in a table and e-mail the
requested document to the requestor. The document itself would no longer
appear on a page.

I know that this is possible - I've requested documents this way from other
sites. My knowledge is limited, though - I use FrontPage 2003 for page
creation and editing, and I can sort of find my way through JavaScript. The
server runs Apache software and the host will activate the FP extensions on
request.

Can someone point me in the direction of some instructions on this sort of a
project? Many thanks.


Steve E.

arccos
To be honest, I haven't ever used FP extensions. I'm pretty sure they
can't do what you want them to do.

Basically, you need two different skills for this project: a
programming language and a database.

Since you're on Apache, your webhost will most likely provide MySQL as
the database software, and provide some sort of interface for it.
You'll need to learn how to create a table, how to insert, and how to
read data out of it. Check with your host to find out what they offer.

For a programming language, I would recommend PHP. It's much easier to
learn than PERL; your other likely option. Focus on form processing.
Again, check with your host to find out what they offer.

Alternatively, you could get someone at rentacoder.com to do it for
you. My guess is for around $50. But you'll need to know what
programming language and database you want to use.

Good Luck!
-Arccos

Serious_Practitioner wrote:
QUOTE
Good day, and thank you in advance for your help.

I would like for visitors to my site to be able to request that a document
be e-mailed to them. At the present time, I allow people to print the page
containing the document - it's time to stop that.

Ideally, someone would open a page and see a form where he/she could order
the document. After entering first and last names, and an e-mail address,
the act of submitting the form would put the data in a table and e-mail the
requested document to the requestor. The document itself would no longer
appear on a page.

I know that this is possible - I've requested documents this way from other
sites. My knowledge is limited, though - I use FrontPage 2003 for page
creation and editing, and I can sort of find my way through JavaScript. The
server runs Apache software and the host will activate the FP extensions on
request.

Can someone point me in the direction of some instructions on this sort of a
project? Many thanks.


Steve E.


William Tasso
Writing in news:alt.www.webmaster
From the safety of the AT&T Worldnet cafeteria
Serious_Practitioner <[Email Removed]> said:

QUOTE
Good day, and thank you in advance for your help.

How do you do?

QUOTE
I would like for visitors to my site to be able to request that a
document
be e-mailed to them.

Just the one document or one from a selection or many selected?

Assuming just the one.

QUOTE
...
the act of submitting the form would put the data in a table

What does the table (assuming db) bring to the party?


QUOTE
and e-mail the requested document to the requestor.

ok - start by using the facilities provided by your host to return a
simple mail based on form data.

If the document is plain text then add the text to your mail and your job
is done.

Assuming doc is pdf or some other that must be treated as an attachment,
check with host/support/admin how to use their facilities to attach the
document to the mail.

I still don't know what the db table is for.

How are you going to prevent spineless w*nk*rs visting your site and
loading in the mail address of a spam-trap?

--
William Tasso

** Business as usual

Norman L. DeForest
On Fri, 8 Jul 2005, Serious_Practitioner wrote:

QUOTE
Good day, and thank you in advance for your help.

I would like for visitors to my site to be able to request that a document
be e-mailed to them. At the present time, I allow people to print the page
containing the document - it's time to stop that.

Ideally, someone would open a page and see a form where he/she could order
the document. After entering first and last names, and an e-mail address,
the act of submitting the form would put the data in a table and e-mail the
requested document to the requestor. The document itself would no longer
appear on a page.

I know that this is possible - I've requested documents this way from other
sites. My knowledge is limited, though - I use FrontPage 2003 for page
creation and editing, and I can sort of find my way through JavaScript. The
server runs Apache software and the host will activate the FP extensions on
request.

Can someone point me in the direction of some instructions on this sort of a
project? Many thanks.

I can't help with what you say you want to do but have a couple of
suggestions that may change what you want to do.

Why not use a script to generate a page with a time-limited URL on it
that links to the file and let them download the file from that? You
could even give them a choice of file format (text, .zip, .gz,
unix/mac/DOS end-of-line characters (lf/cr/crlf)) to reduce download
time and/or eliminate headaches in converting end-of-line markers.

If you insist on using email, make sure you include a verification step
in the process. Send a one-time email with a random token to the given
email address saying something like:

On Fri, 8 Jul 2005, 12:56:27 -0400 someone, connecting from IP
address 12.34.56.78 and claiming to be you, filled in our form at
http://www.foobar.invalid/cgi-bin/foobar.cgi
and requested that the the file, "foobar.txt" (123456 bytes) be
emailled to your address. If this was indeed you, please reply
to this message with the strings "B3ghTmpL" and "OK" added to the
subject to verify this. If it was not you, you may do nothing in
which case, we will not send any file to you or you may reply with
the token "B3ghTmpL" and "BAD" added to the subject, in which case
we will also reject any other subsequent submissions claiming to
be from you.

.... and then handle things as described in that email. Do not include any
advertising copy in the email.

If you don't use some form of verification, especially if the documents
are at all large, your form could be misused by someone for the purpose of
harrassment. An abuser who found your form could fill in the names and
email addresses of those he wanted to harrass and you would get the blame
for sending the large unsolicited files. You could even lose your account
for spamming. (The time-limited download URL would eliminate that
problem.)

--
Windows is *not* a "Toy OS". A screenshot of my desktop (Icons (including
complete alphabet, A to Z) and wallpaper coming soon to a website near (or
far from) you. Toilet-flushing sound available separately on request):
http://www.chebucto.ns.ca/~af380/MyDeskTop-Jun-22-2005.gif

Matt-the-Hoople
In news:[Email Removed],
arccos <[Email Removed]> walked into the bar with a grape in each nostril
and said to the bartender:
:: To be honest, I haven't ever used FP extensions. I'm pretty sure they
:: can't do what you want them to do.

Stop top posting

<snip />
:: rentacoder.com

never mind. You have no hope of ever understanding.

Marc Bissonnette
"Serious_Practitioner" <[Email Removed]> wrote in
news:jsBze.401256$[Email Removed]:

QUOTE
Good day, and thank you in advance for your help.

I would like for visitors to my site to be able to request that a
document be e-mailed to them. At the present time, I allow people to
print the page containing the document - it's time to stop that.

Ideally, someone would open a page and see a form where he/she could
order the document. After entering first and last names, and an e-mail
address, the act of submitting the form would put the data in a table
and e-mail the requested document to the requestor. The document
itself would no longer appear on a page.

I know that this is possible - I've requested documents this way from
other sites. My knowledge is limited, though - I use FrontPage 2003
for page creation and editing, and I can sort of find my way through
JavaScript. The server runs Apache software and the host will activate
the FP extensions on request.

Can someone point me in the direction of some instructions on this
sort of a project? Many thanks.

http://search.cpan.org/~yves/MIME-Lite-
3.01/lib/MIME/Lite.pm#Attach_a_GIF_to_a_text_message

or

http://tinyurl.com/dr3wy

and a form.

Okay, just deleted the quick and dirty reply that I *did* type, 'cuz I
was curious how to do this.

This works: (Just tested it and got the email, along with the attachment)
(This is perl, btw)

#!/usr/bin/perl
use CGI;
use MIME::Lite;
$q = new CGI;
print $q->header();
use CGI::Carp qw(fatalsToBrowser);
$cgiurl = 'http://www.beachburg.com/cgi-bin/mailattach.cgi';
%in = $q->Vars;
if ($in{f} eq undef) {
$in{f} = 'ShowForm';
}
$func = $in{f};
&$func;

sub ShowForm {
print "<HTML><BODY><FORM ACTION = "$cgiurl" METHOD=POST>n";
print "Your Name: <INPUT TYPE=TEXT NAME="name"><BR>n";
print "Your Email: <INPUT TYPE=TEXT NAME="email"><BR>n";
print "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE="SUBMIT">n";
print "<INPUT TYPE=HIDDEN NAME="f" VALUE="SendData">n";
print "</FORM>n</BODY>n</HTML>";
exit;
}

sub SendData {
if ($in{name} eq undef or $in{email} eq undef) {
print "<HTML><BODY>You need to enter name and email address.
</BODY></HTML>n";
exit;
}
$msg = MIME::Lite->new(
From =>'[Email Removed]',
To =>"$in{email} ($in{name})",
Subject =>'Message with attachment',
Type =>'multipart/mixed'
);

### Add parts (each "attach" has same arguments as "new"):
$msg->attach(Type =>'TEXT',
Data =>"Here is the attached file you requested"
);
$msg->attach(Type =>'application/pdf',
Path =>'/var/www/sites/beachburg.com/htdocs/foo.pdf',
Filename =>'foo.pdf',
Disposition => 'attachment'
);
$msg->send;
print "done";
}

You need to have the CGI module installed on your server (*should* be
there by default)
You also need to have MIME::Lite installed on your server (Might not be -
wasn't installed on my RHEL / Apache 2 box by default - but now that I
know this sucker works, it's a handy thing to know :)

You can test this at
http://www.beachburg.com/cgi-bin/mailattach.cgi

The code is identical to the above (I've no interest in being a spammer,
so I'm not trapping any addies - honest :)


--
Marc Bissonnette
CGI / Database / Web Management Tools: http://www.internalysis.com
Looking for a new ISP? http://www.canadianisp.com

Marc Bissonnette
"arccos" <[Email Removed]> wrote in
news:[Email Removed]:

QUOTE
To be honest, I haven't ever used FP extensions. I'm pretty sure they
can't do what you want them to do.

Basically, you need two different skills for this project: a
programming language and a database.

Why a DB ? If all he's collecting is the names and email addresses, then
a text file works fine, too (Which reminds me, I forgot to put that in my
original solution).

QUOTE
Since you're on Apache, your webhost will most likely provide MySQL as
the database software, and provide some sort of interface for it.
You'll need to learn how to create a table, how to insert, and how to
read data out of it. Check with your host to find out what they offer.

For a programming language, I would recommend PHP. It's much easier to
learn than PERL; your other likely option. Focus on form processing.
Again, check with your host to find out what they offer.

Hey! Don't be scaring people off perl :) It's a pretty decent and *very*
powerful language - and *much* easier to learn (IMO) than the C based
languages like Java and ASP.

QUOTE
Alternatively, you could get someone at rentacoder.com to do it for
you. My guess is for around $50. But you'll need to know what
programming language and database you want to use.

Or, you could hope some perl coder will come along and put the whole
solution in this newsgroup for free :)
(See my response to the OP)


QUOTE
Serious_Practitioner wrote:
Good day, and thank you in advance for your help.

I would like for visitors to my site to be able to request that a
document be e-mailed to them. At the present time, I allow people to
print the page containing the document - it's time to stop that.

Ideally, someone would open a page and see a form where he/she could
order the document. After entering first and last names, and an
e-mail address, the act of submitting the form would put the data in
a table and e-mail the requested document to the requestor. The
document itself would no longer appear on a page.

I know that this is possible - I've requested documents this way from
other sites. My knowledge is limited, though - I use FrontPage 2003
for page creation and editing, and I can sort of find my way through
JavaScript. The server runs Apache software and the host will
activate the FP extensions on request.

Can someone point me in the direction of some instructions on this
sort of a project? Many thanks.



--
Marc Bissonnette
CGI / Database / Web Management Tools: http://www.internalysis.com
Looking for a new ISP? http://www.canadianisp.com

Marc Bissonnette
Marc Bissonnette <[Email Removed]> wrote in
news:[email protected]:

QUOTE
"Serious_Practitioner" <[Email Removed]> wrote in
news:jsBze.401256$[Email Removed]:

Good day, and thank you in advance for your help.

I would like for visitors to my site to be able to request that a
document be e-mailed to them. At the present time, I allow people to
print the page containing the document - it's time to stop that.

Ideally, someone would open a page and see a form where he/she could
order the document. After entering first and last names, and an
e-mail address, the act of submitting the form would put the data in
a table and e-mail the requested document to the requestor. The
document itself would no longer appear on a page.

I know that this is possible - I've requested documents this way from
other sites. My knowledge is limited, though - I use FrontPage 2003
for page creation and editing, and I can sort of find my way through
JavaScript. The server runs Apache software and the host will
activate the FP extensions on request.

Can someone point me in the direction of some instructions on this
sort of a project? Many thanks.

Sorry for self-replying - forgot to add in the storage of the names and
addies in a text file:

#!/usr/bin/perl
use CGI;
use MIME::Lite;
$q = new CGI;
print $q->header();
use CGI::Carp qw(fatalsToBrowser);
$cgiurl = 'http://www.beachburg.com/cgi-bin/mailattach.cgi';
%in = $q->Vars;
if ($in{f} eq undef) {
$in{f} = 'ShowForm';
}
$func = $in{f};
&$func;

sub ShowForm {
print "<HTML><BODY><FORM ACTION = "$cgiurl" METHOD=POST>n";
print "Your Name: <INPUT TYPE=TEXT NAME="name"><BR>n";
print "Your Email: <INPUT TYPE=TEXT NAME="email"><BR>n";
print "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE="SUBMIT">n";
print "<INPUT TYPE=HIDDEN NAME="f" VALUE="SendData">n";
print "</FORM>n</BODY>n</HTML>";
exit;
}

sub SendData {
if ($in{name} eq undef or $in{email} eq undef) {
print "<HTML><BODY>You need to enter name and email address.
</BODY></HTML>n";
exit;
}
$msg = MIME::Lite->new(
From =>'[Email Removed]',
To =>"$in{email} ($in{name})",
Subject =>'Message with attachment',
Type =>'multipart/mixed'
);

### Add parts (each "attach" has same arguments as "new"):
$msg->attach(Type =>'TEXT',
Data =>"Here is the attached file you requested"
);
$msg->attach(Type =>'application/pdf',
Path =>'/var/www/sites/beachburg.com/htdocs/foo.pdf',
Filename =>'foo.pdf',
Disposition => 'attachment'
);
$msg->send;
open (WLOG,">>maillog.txt") or die ("Cannot open maillog for
writing: $!");
pring WLOG "$in{name}|$in{email}n";
close WLOG;
print "done";
}

(The script at http://www.beachburg.com/cgi-bin/mailattach.cgi does not
have the logging bit)

--
Marc Bissonnette
CGI / Database / Web Management Tools: http://www.internalysis.com
Looking for a new ISP? http://www.canadianisp.com

Doc O'Leary
In article
<jsBze.401256$[Email Removed]>,
"Serious_Practitioner" <[Email Removed]> wrote:

QUOTE
I would like for visitors to my site to be able to request that a document
be e-mailed to them.

You can't do that. All they can do is request that an email be sent to
a particular address. If you lack a confirmation system, you run the
risk of being flagged a spammer.

QUOTE
At the present time, I allow people to print the page
containing the document - it's time to stop that.

Why? What benefits are there to your collecting emails instead of just
feeding up web content?

arccos
Marc Bissonnette wrote:
QUOTE
"arccos" <[Email Removed]> wrote in
news:[Email Removed]:

To be honest, I haven't ever used FP extensions. I'm pretty sure they
can't do what you want them to do.

Basically, you need two different skills for this project: a
programming language and a database.

Why a DB ? If all he's collecting is the names and email addresses, then
a text file works fine, too (Which reminds me, I forgot to put that in my
original solution).

I thought about that, too, but a text file is a form of a database. In
this case, it would be easier than setting up a seperate dedicated
database, but I've always found that it's better to not limit your
capabilites by using a simple text file.

QUOTE

Since you're on Apache, your webhost will most likely provide MySQL as
the database software, and provide some sort of interface for it.
You'll need to learn how to create a table, how to insert, and how to
read data out of it. Check with your host to find out what they offer.

For a programming language, I would recommend PHP. It's much easier to
learn than PERL; your other likely option. Focus on form processing.
Again, check with your host to find out what they offer.

Hey! Don't be scaring people off perl :) It's a pretty decent and *very*
powerful language - and *much* easier to learn (IMO) than the C based
languages like Java and ASP.


I use perl myself, but to avoid the potential war here about it, I'll
just say I prefer PHP and ASP to perl, and find that easier for the
first-time programmers I've taught.

QUOTE
Alternatively, you could get someone at rentacoder.com to do it for
you. My guess is for around $50. But you'll need to know what
programming language and database you want to use.

Or, you could hope some perl coder will come along and put the whole
solution in this newsgroup for free :)
(See my response to the OP)


Point taken.

-Arccos

QUOTE
Serious_Practitioner wrote:
Good day, and thank you in advance for your help.

I would like for visitors to my site to be able to request that a
document be e-mailed to them. At the present time, I allow people to
print the page containing the document - it's time to stop that.

Ideally, someone would open a page and see a form where he/she could
order the document. After entering first and last names, and an
e-mail address, the act of submitting the form would put the data in
a table and e-mail the requested document to the requestor. The
document itself would no longer appear on a page.

I know that this is possible - I've requested documents this way from
other sites. My knowledge is limited, though - I use FrontPage 2003
for page creation and editing, and I can sort of find my way through
JavaScript. The server runs Apache software and the host will
activate the FP extensions on request.

Can someone point me in the direction of some instructions on this
sort of a project? Many thanks.



--
Marc Bissonnette
CGI / Database / Web Management Tools: http://www.internalysis.com
Looking for a new ISP? http://www.canadianisp.com


Marc Bissonnette
"arccos" <[Email Removed]> wrote in
news:[Email Removed]:

QUOTE


Marc Bissonnette wrote:
"arccos" <[Email Removed]> wrote in
news:[Email Removed]:

To be honest, I haven't ever used FP extensions. I'm pretty sure
they can't do what you want them to do.

Basically, you need two different skills for this project: a
programming language and a database.

Why a DB ? If all he's collecting is the names and email addresses,
then a text file works fine, too (Which reminds me, I forgot to put
that in my original solution).

I thought about that, too, but a text file is a form of a database. In
this case, it would be easier than setting up a seperate dedicated
database, but I've always found that it's better to not limit your
capabilites by using a simple text file.

Good point - Though if the OP is a neophyte at any form of CGI
programming, using text is easier to start; Though to tell you the truth,
I wish I'd learned DB programming right off the start, rather than text
files. ( Problem of the self-taught -> Sometimes the learning priorities
you assign yourself are just plain short-sighted :)

QUOTE
Since you're on Apache, your webhost will most likely provide MySQL
as the database software, and provide some sort of interface for
it. You'll need to learn how to create a table, how to insert, and
how to read data out of it. Check with your host to find out what
they offer.

For a programming language, I would recommend PHP. It's much easier
to learn than PERL; your other likely option. Focus on form
processing. Again, check with your host to find out what they
offer.

Hey! Don't be scaring people off perl :) It's a pretty decent and
*very* powerful language - and *much* easier to learn (IMO) than the
C based languages like Java and ASP.


I use perl myself, but to avoid the potential war here about it, I'll
just say I prefer PHP and ASP to perl, and find that easier for the
first-time programmers I've taught.

:) I guess it depends on the teaching style/methods; Some purists insist
that it's necessary to first learn everything the long way, then move on
to the time-savers. I've found that while that's a really good idea in
woodworking (always learn the hand tools before the power tools),
programming doesn't always benefit like that. The rare times I teach
perl, I'll show em the very basics of CGI.pm first; i.e. The first lines
of your scripts (for web apps) should always be:

#!/usr/bin/perl
use CGI;
$q = new CGI;
print $q->header();

With those four lines memorized, simply doing

print "Whatever you want here";

spits stuff out to the browser - people tend to get hooked from there :)

(Though I'll admit perl's regex stuff can really be intimidating at
first, it's really, really, *really* worth it to learn - Another thing I
put off for far too long)

QUOTE
Alternatively, you could get someone at rentacoder.com to do it for
you. My guess is for around $50. But you'll need to know what
programming language and database you want to use.

Or, you could hope some perl coder will come along and put the whole
solution in this newsgroup for free :)
(See my response to the OP)

Point taken.

:) Actually, I'd run across the need earlier in the week where I had
originally said that I didn't know how to make mail attachments via CGI,
but I could learn it - the client said not to worry, they'd use another
method, so the OP's request was timely in that I wanted to look it up and
learn it anyway :)

[snip]


--
Marc Bissonnette
CGI / Database / Web Management Tools: http://www.internalysis.com
Looking for a new ISP? http://www.canadianisp.com


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.