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
Solved

How do you process a form using perl?

Posted on 2004-09-03
7
203 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WSDL Soap Error 12 281
Menu Trouble 8 46
Problem to picture file 3 81
When using Laravel when is better to use Alias and when is better to use Virtual Hosts? 6 125
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
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 …
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 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