Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Forms and CGI

Forms and CGI
Thread Tools
Psychonaut
Mac Enthusiast
Join Date: Nov 2002
Location: Republic of New Hampshire
Status: Offline
Reply With Quote
Jun 2, 2003, 02:58 PM
 
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!
     
ameat
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Jun 2, 2003, 05:42 PM
 
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]
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jun 3, 2003, 06:35 AM
 
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...
     
Arkham_c
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Jun 3, 2003, 09:32 AM
 
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
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Jun 3, 2003, 01:50 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:00 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,