PDA

View Full Version : Formmail.. a bit stuck


E-Liam
05-05-2008, 12:00 PM
Hi all,

I'm trying to set up formmail on my site, but cant get it to work. I get an error 500 page instead. This is a test page with the same script, as the original has a lot of fields. If I can get this one working it should be the same for the main one???!!!

The mailtest email addy is real, but temporary, so I've left it in.


Form
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>What is your favorite animal ?</title>
<link rel="stylesheet" type="text/css" href="/css/nms.css" />
</head>
<body>
<form method="post" action="/cgi-bin/moonbug.pl">
<INPUT TYPE="hidden" NAME="recipient" VALUE="mailtest@hanworthclub.co.uk">
<input type="hidden" name="subject" value="Favorite Animal" />
<table>
<tr>
<td>What is your name ?</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td>What is your favorite animal ?</td>
<td><input type="text" name="animal" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" /></td>
</tr>
</table>
</form>
</body>
</html>

Script (moonbug.pl)
#!/usr/bin/perl -w
##############################################################################
# nms Formmail Version 3.14c1 #
# Copyright 2001 London Perl Mongers All rights reserved #
# Created 11/11/01 Last Modified 08/11/04 #
# Matt's Script Archive: http://www.scriptarchive.com/ #
##############################################################################
# nms Formmail has been created as a drop in replacement for the FormMail #
# found at Matt's Script Archive. Both the original and nms versions of this #
# script can be found at the above URL. Support for nms Formmail is #
# available through: nms-cgi-support@lists.sourceforge.net #
##############################################################################
#
# NMS FormMail Version 3.14c1
#

use strict;
use vars qw(
$DEBUGGING $emulate_matts_code $secure %more_config
$allow_empty_ref $max_recipients $mailprog @referers
@allow_mail_to @recipients %recipient_alias
@valid_ENV $date_fmt $style $send_confirmation_mail
$confirmation_text $locale $charset $no_content
$double_spacing $wrap_text $wrap_style $postmaster
$address_style
);

# PROGRAM INFORMATION
# -------------------
# FormMail.pl Version 3.14c1
#
# This program is licensed in the same way as Perl
# itself. You are free to choose between the GNU Public
# License <http://www.gnu.org/licenses/gpl.html> or
# the Artistic License
# <http://www.perl.com/pub/a/language/misc/Artistic.html>
#
# For help on configuration or installation see the
# README file or the POD documentation at the end of
# this file.

# USER CONFIGURATION SECTION
# --------------------------
# Modify these to your own settings. You might have to
# contact your system administrator if you do not run
# your own web server. If the purpose of these
# parameters seems unclear, please see the README file.
#
BEGIN
{
$DEBUGGING = 1;
$emulate_matts_code= 0;
$secure = 1;
$allow_empty_ref = 1;
$max_recipients = 5;
$mailprog = '/usr/sbin/sendmail -oi -t';
$postmaster = 'mailtest@hanworthclub.co.uk';
@referers = qw(www.hanworthclub.co.uk);
@allow_mail_to = qw(mailtest@hanworthclub.co.uk);
@recipients = ();
%recipient_alias = ();
@valid_ENV = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
$locale = '';
$charset = 'iso-8859-1';
$date_fmt = '%A, %B %d, %Y at %H:%M:%S';
$style = '';
$no_content = 0;
$double_spacing = 1;
$wrap_text = 0;
$wrap_style = 1;
$address_style = 0;
$send_confirmation_mail = 0;
$confirmation_text = <<'END_OF_CONFIRMATION';
From: you@your.com
Subject: form submission

Thank you for your form submission.

END_OF_CONFIRMATION

I set up a classified ads page on a previous incarnation, and the shebang and sendmail paths are correct.. or they used to be anyway. :thumbsup:

Cheers

Liam

E-Liam
05-05-2008, 01:00 PM
Hi,

I've got it sorted.. I'm not sure exacly which bit, but it was my original form that was the problem. If I can work it out, I'll post it in case it helps someone else. Thanks for looking anyway.

Cheers

Liam

E-Liam
05-05-2008, 01:19 PM
Hi,

a friend on another forum pointed out my error..

<INPUT TYPE="hidden" NAME="recipient" VALUE="mailtest@hanworthclub.co.uk">

should have been..
<INPUT TYPE="hidden" NAME="recipient" VALUE="mailtest@hanworthclub.co.uk" />

I didn't close the input field. A silly mistake but it just shows how a simple little thing can muck up all that work.

Cheers

Liam

FishMonger
05-05-2008, 04:45 PM
You should not put the recipient address in a hidden form field. That opens a doorway for spammers. The recipient should be configured in the BEGIN block of the script.

E-Liam
05-05-2008, 05:21 PM
Hi Fishmonger,

I've got it now as ..

%recipient_alias = ('1' => 'mailtest@hanworthclub.co.uk',);

<INPUT TYPE="hidden" NAME="recipient" VALUE="1" />

is that what you mean? I intended doing that anyway, and set up the mailtest addy just for debugging purposes. It'll be deleted once everything is set up to my liking.

Ooh... while you're here.. :)

Now I've got the nuts and bolts working, I'm making it look pretty..

If you don't set up your own thankyou page, you get a nice ordered list of all the completed fields that displays what you, as the sender, have just submitted, as the default setting in the script. ie.

Monday...Shift One...5.5 Hours: name 1

Tuesday...Shift One...5.5 Hours: name 2

Tuesday...Shift Two...5.0 Hours: name 1

Wednesday (T)...Shift One...4.0 Hours: name3

Thursday...Shift One...5.5 Hours: name 4

Friday...Shift One...6.5 Hours: name 1

Friday...Shift Two...4.5 Hours: name 3






What I wanted to do was to incorporate that into the thankyou page. It's for submission of hours worked for club staff. It'll be behind a server password, so it'll be secure, and it would be useful for the chap who's inputting the info on the form to get back the info to both double check and to also print off for his own records.

I thought, whilst away from the PC that the page source of the basic return might contain a code string, that would then generate the data into that page.. taking it from the *.pl file. It didn't, so I don't know where to look for that. Or does this mean that in order to display the data like that, I'd need to build my css into the pl file itself?

Ideally I'd like it to submit at the user's end, a printable *.doc or *.txt file, but as you can see, the chances of me working that out for myself are somewhere between slim and none.!:confused: It also has to be easy for the user to do, as he's not really literate with computers beyond basic stuff.

as a final thought, if it could generate a *.xls file, I'll have your babies... :p:D

Cheers

Liam