Solved

How do you process a form using perl?

Posted on 2004-09-03
7
208 Views
Last Modified: 2010-04-06
at the moment i am using the asp equivilant, but the webserver i am hosting with doesnt allow asp:

<%
set objmail = server.CreateObject("CDONTS.NewMail")
   
objmail.from = "Web Form"
objmail.to = "xxx@xx.com"
objmail.Subject = "Registration"
objmail.Body =  "Email: " & request.form("Email")
objmail.Send
set objmail = nothing
response.redirect("http://")
%>

does anyone know how to convert this to perl?
0
Comment
Question by:Jyontex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11971637
Hi

If possible, use PHP or something like that. For Perl, if your server is Unix, you can simply use sendmail. Otherwise, you need to download other modules, or etc. For a sendmail example, something like this would work:


open(MAIL, "| /usr/lib/sendmail -t -oi") or die "Can't fork for sendmail: $!\nCould be wrong path.";

my $to = "xxx@xx.com";
my $from = "Web Form";
my $subject = "Registration";
my $body = "Email: " . param("Email");

print MAIL "To: $to";
print MAIL "From: $from";
print MAIL "Subject: $subject";
print MAIL $body;


Regards,
Zyloch
0
 

Author Comment

by:Jyontex
ID: 11971746
unfortunatly the hosting solution only allows pl for processing.  I have spoken to the people i host with and they say its a Linux server.

Also tried the script above, and get:  CGIWrap Error: Script Execution Failed  

Any idea what that could be?
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11971796
Make sure the script is uploaded in ascii mode and not binary.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Accepted Solution

by:
ziffgone earned 250 total points
ID: 11986900
Hello Jyontex,

First off, make sure you know your paths to Perl and Sendmail. Your hosting company will be able to tell you this.

Depending on the Perl Modules installed on your hosting company's server, this should be a replacement for the above ASP you posted:

Begin Code ----------------------------------------------------------------

#!/usr/bin/perl -w
# make sure the above is correct path to perl from your server and is the first line in the file.
use strict;
use CGI;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
# Remove the above line after all debugging is complete.

my($sendmail,$to,$from,$body,$email,$subject,$reply);

$to = "xxx@xx.com";
$from = "YourSite.com Web Form <youremail@yourdomain.com>";
$reply = "youremail@yourdomain.com";
$subject = "Registration";
$email = param('Email');
$body = "Email: ".$email;
$sendmail = "/usr/sbin/sendmail";
# Make sure the above line is the correct path to sendmail on your server.

# Now it is time to send the e-mail.
open(MAIL, "|$sendmail -t -oi") or die "Cannot open $sendmail: $!";
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Reply-to: $reply\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-type: text/plain\n\n";
print MAIL $body."\n\n";
close(MAIL);

# Email sent, redirect to Thank You page:
my $q = new CGI;
print $q->redirect( "http://www.yoursite.com/thankyou.html" );

End Code ----------------------------------------------------------------

Using the "use CGI::Carp qw(warningsToBrowser fatalsToBrowser);" will tell you of any script errors and what line they occur on for debugging. Using "strict" hightens the security of the script.

Hope that helps you out.

Regards...
0
 
LVL 14

Expert Comment

by:ziffgone
ID: 11986908
Another note Jyontex, incase you are not familiar with such, make sure you CHMOD the file to 755.

Regards...
0
 

Author Comment

by:Jyontex
ID: 11998494
Thank you....that was very detailed.
0
 
LVL 14

Expert Comment

by:ziffgone
ID: 12002161
No problem, my pleasure to help out.

Regards...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is the normal amount of queries 5 89
Swiper slider stops between pages 11 54
cookies analysis tools 2 110
Where does legacy ASP.NET initialize language? 2 97
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question