Re: Limit FORM mailer submissions to 5 on website, then pause until reviewed by webmaster
- From: "Matt Garrish" <mgarrish@xxxxxxxxx>
- Date: 27 Sep 2006 14:59:02 -0700
Lance wrote:
Hi everyone,
I was hoping someone could help or point me in the right direction.
I would like to install an intelligent Form mailer on my up and coming
website.
The purpose of the Form mailer will be to either submit to a database
or send an email. However, I would like the form mailer to pause and
prevent any further submissions after 5 submits. During this period new
users visiting the page should automatically be redirect to another URL
displaying a message similar to '5 forms have already been submitted,
please check back soon'. Once I have reviewed the 5 submitted forms,
I should then be allowed to open the form up again.
[realizing this has absolutely nothing to do with Perl...]
Your requirements are a bit vague, but I'm assuming all submissions go
into the database and the email goes out when you confirm the
submissions? If that is the case, the standard approach is to add a
confirmation column to your table. You can then count the number of
unconfirmed entries before displaying the page and if it already equals
five display your alternate text. You just have to bear in mind that
multiple people could see the form while it still only registers 4
submissions, and they could all try to submit to be the fifth, which
might make some users unhappy when they find out they're actually
number 6,7,8,9... and rejected after filling out the form. It also
means that as you confirm the entries new ones will be able to go in.
If you don't want to be counting all the time from your database, there
are other options but they require a good deal of care to implement.
One would be to create a separate table with just the current count and
check it each time (but you'll need to properly lock the tables during
transactions to ensure accuracy). Another would be to use a text file
for the count, holding a lock on it while the database update occurs
and then wrting the new count. You can then review the five submitted
entries at your leisure but until you reset the count table/text file
no one can submit (i.e., your database won't keep filling up as you
review).
With a limit of 5 it doesn't sound like you're dealing with enough
traffic that you'd need to worry yourself about the latter options,
though.
To give this some Perl content, there are many modules available that
make writing a script like you've described very simple. For databases,
have a look at DBI (and probably DBD::MySQL), and for sending emails
there's Net::SMTP, Mail::Mailer, etc.
Just don't post back asking someone here to write it for you, unless
you enjoy being flamed...
Matt
.
- Follow-Ups:
- References:
- Prev by Date: Re: How to dynamically generate function name and call it?
- Next by Date: Re: How to dynamically generate function name and call it?
- Previous by thread: Limit FORM mailer submissions to 5 on website, then pause until reviewed by webmaster
- Next by thread: Re: Limit FORM mailer submissions to 5 on website, then pause until reviewed by webmaster
- Index(es):