Koozali.org: home of the SME Server

Perl question for Form Handling

Offline Ness

  • ****
  • 108
  • +0/-0
    • http://www.tapiochre.co.uk
Perl question for Form Handling
« on: August 17, 2006, 12:51:42 PM »
This email started in the 6.X forum. Have moved it here as it probably lives here.

I'm a SME 6.0.1 user

Am trying my best to integrate a few lines of perl that will let me have an email forms handler. No matter what I use as the shebang, I get an Internal Server Error when I submit the data to the script for processing (but it may not be anything to do with the shebang thing).

I have CHMODed the cgi file to 755, its CHOWN values are root:admin (only because I logged in as root to do the integration)

I have a virtual domain linked to an ibay.

I have enabled the cgi-bin facility for the ibay in question, put the email handler script )I called it postit.cgi) in the cgi-bin folder.

The HTML calls up the following action value:

Code: [Select]

<form action="http://www.mydomain.co.uk/cgi-bin/postit.cgi" method="post" name="MyForm">
...
inputs and submit stuff
</form>


The cgi script looks like this

Code: [Select]

#!/usr//bin/perl -w

use strict;
use CGI;

my $query = CGI->new();
my @names = $query->param;

my $noemail="";
my $from = $query->param('email');
if ($from eq ""){
   $from = "noname\@mydomain.co.uk";
   }else{
   $from =~ s/@/\@/;
   $noemail="true";
   }

my $myself = "sales\@mydomain.co.uk";
open (MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $myself \nFrom: $from\n";
   my $subj = $query->param('subject');
   if ($subj eq ""){
   print MAIL "Subject: Form info entered\n";
   }else{
   print MAIL "Subject: " . $subj . "\n";
   }

foreach my $name (@names){
    my @values = $query->param( $name );
   if ((join ", ", @values) && ($name ne "subject") && ($name ne "email")){
   print MAIL $name . " = " . (join ", ", @values) . "\n";
   }
}
close (MAIL);

print $query->redirect("http://www.mydomain.co.uk/thankyou.html");




Can anyone spot where my problem lies? I've looked through my Apache book but have hit a bit of a dead end. The error message reads:

Code: [Select]

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@tapiochre.co.uk and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



but I see no evidence in the logs to this problem, unless I'm looking in the wring place.


Chris
Chris Elliott - SME Server user and helper

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Perl question for Form Handling
« Reply #1 on: August 22, 2006, 09:07:26 AM »
Quote from: "Ness"

but I see no evidence in the logs to this problem, unless I'm looking in the wring place.


Look in /var/log/httpd/error_log. Also be sure to run "perl -cw script_name".

Offline Ness

  • ****
  • 108
  • +0/-0
    • http://www.tapiochre.co.uk
Perl question for Form Handling
« Reply #2 on: August 22, 2006, 09:59:19 AM »
Thanks Charlie

In the end, and only last night, I looked at the formbuilder that Ray posted the link for. It works very well and I now have the forms I need, running on the site.

For any newbies who are unfamiliar with Perl, the formbuilder is a great and easy tool, requiring only a minimum of HTML expertise to customise.

Thanks again

Chris
Chris Elliott - SME Server user and helper

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Perl question for Form Handling
« Reply #3 on: August 22, 2006, 10:21:56 AM »
Quote from: "Ness"

In the end, and only last night, I looked at the formbuilder that Ray posted the link for.


What formbuilder is that?

Offline Ness

  • ****
  • 108
  • +0/-0
    • http://www.tapiochre.co.uk
Perl question for Form Handling
« Reply #4 on: August 22, 2006, 10:26:53 AM »
Quote from: "CharlieBrady"
What formbuilder is that?


From SME 6.X Forum, where my query started...

http://forums.contribs.org/index.php?topic=33263.0

Chris
Chris Elliott - SME Server user and helper