|
|
Forms and CGI
|
|
|
|
Mac Enthusiast
Join Date: Nov 2002
Location: Republic of New Hampshire
Status:
Offline
|
|
As I am a begining HTML student it has proven hard to delve into CGI and Perl and still keep my senses. My objective is to implement an HTML form that sends the result to an e-mail address. My question to you all is how can I use a CGI script to accomplish this? Any example scripts?
|
DBGFHRGL!
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status:
Offline
|
|
Originally posted by Psychonaut:
As I am a begining HTML student it has proven hard to delve into CGI and Perl and still keep my senses. My objective is to implement an HTML form that sends the result to an e-mail address. My question to you all is how can I use a CGI script to accomplish this? Any example scripts?
...i haven't tested the following but it should work; albeit crudely. you might want to look into the perldoc pages for CGI.pm: http://perldoc.com/perl5.8.0/lib/CGI.html for a bit more customization of your output. you might also want to redirect your user to another page after submitting their data.
(disregard the php tagging...the syntax for basic perl and php are close enough that it allows us to get some pretty syntax coloring...)
hope this helps,
amit
[php]
#!/usr/bin/perl -wT
use Strict;
use CGI;
my $q = new CGI();
# Generate your email body...
# The Dump() method prints out all
# submitted name value pairs.
my $toMail = $query->Dump();
# Send it...
open (MAIL,"|/usr/sbin/sendmail -t") or die "Unable to open email: $!";
print MAIL $toMail;
close(MAIL);
exit(0);
[/php]
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
PLEASE! PLEASE! For the love of god don't use the formmail.pl script from Matt's Archive. At least if it isn't configured properly.
We've just had a lengthly and costly problem with our web hosting company where a security hole can lead to people abusing this script to send spam. It's to do with the fact you can send all sorts of form values to set the parameters of the script and it's trivial to bypass any 'security' measures it may have.
Write yer own and make it secure!
|
Computer thez nohhh...
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
There are numerous scripts out there to send a form via email. I would say this -- CGI is a dinosaur these days. Most people would solve this problem with PHP, JSP, servlets, ColdFusion, or some other application server solution rather than strict CGI. CGI has lots of serious limitations, including security and performance.
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
|
|
|
|
|
|
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
Originally posted by Simon Mundy:
PLEASE! PLEASE! For the love of god don't use the formmail.pl script from Matt's Archive. At least if it isn't configured properly.
what he said!
check out the rewritten version, by the London Perl Mongers. you can find replacements for all Matt's scripts there
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|