Solved

How do you process a form using perl?

Posted on 2004-09-03
7
194 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XML problem with Internet Explorer 7 31
Collapseable list of URLs. 10 100
MVC and Angular 2 72
Fixed div within Bootstrap carousel item 11 30
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 …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now