Solved

How do you process a form using perl?

Posted on 2004-09-03
7
199 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

776 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