Solved

How do you process a form using perl?

Posted on 2004-09-03
7
204 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
  • 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

Industry Leaders: 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
wordpress limitations 4 134
CSS display:none AND display:block on same element 3 110
Create associate webpages / websites 3 98
Import data into excel from web page 10 110
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

713 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