【问题标题】:Perl script not processing html form correctlyPerl 脚本未正确处理 html 表单
【发布时间】:2015-11-09 15:07:17
【问题描述】:

我正在使用来自 London Perl mongers 的 formmail Perl 脚本(Matt 的脚本存档)来处理我创建的几个 Web 表单。我在 cgi-bin 中有脚本,它似乎可以工作;但是,电子邮件输出只是一个没有格式的长列表。我正在使用记事本中的 Perl 脚本,并且在 Windows 计算机上。我只做了一些修改来为我的客户个性化脚本。我现在几乎没有关于 Perl 的任何事情。我以前用过这个脚本;但我不知道为什么输出是一个没有格式的长列表。我通过服务器的 cpanel 上传了脚本,因为我无法使用我当前的 ftp 程序将它传送到 ftp。他们使用的服务器很旧而且显然不安全。我不知道这是否有区别。如何使输出类似于普通电子邮件而不仅仅是列表。

电子邮件如下所示:

Below is the result of your feedback form.  It was submitted by
hello () on Thursday, August 13, 2015 at 17:35:02
---------------------------------------------------------------------------
todayDate: 08/13/2015
ssn: 123456789
refer: self
birthdate: 08/02/2015
age: 32
gender1: Female
religion: yes
ethnicity: ethnic
address: 1234
city: big
state: CA
zip: 12345
homephone: 5105105100 32135684
workphone: 5105105100
cellphone: 5105105100
creditcard: na
nameOnCard: na
Occupation: work
employerName: hello there
employerAddress: 1234 street
employerCity: all city
employerState: CA
employerZip: 12345
education: BA Degree
inSchool2: No
marriedOrcommit: Yes
howLong: forever
namePartner: honey
occupationPartner: working hard
youPrev: none

我正在使用以下 Perl 脚本:

#!/usr/bin/perl -wT
#
# 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    = 2;
  $mailprog          = '/usr/lib/sendmail -oi -t';
  $postmaster        = 'sylviavanhorn@gmail.com';
  @referers          = qw(expressivehearts.com localhost);
  @allow_mail_to     = qw(sylviavanhorn@gmail.com localhost);
  @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             = '/public/css/jane.css';
  $no_content        = 0;
  $double_spacing    = 0;
  $wrap_text         = 0;
  $wrap_style        = 1;
  $address_style     = 0;
  $send_confirmation_mail = 0;
  $confirmation_text = <<'END_OF_CONFIRMATION';
From: expressivehearts@gmail.com
Subject: New Client Forms Submission

Thank you for your submission.

END_OF_CONFIRMATION

# You may need to uncomment the line below and adjust the path.
# use lib './lib';

# USER CUSTOMISATION SECTION
# --------------------------
# Place any custom code here

# Email Header
print MAIL "To: $postmaster\n";
print MAIL "From: $realname\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Content-type: text/html\n";




# USER CUSTOMISATION << END >>
# ----------------------------
# (no user serviceable parts beyond here)
}

#
# The code below consists of module source inlined into this
# script to make it a standalone CGI.

请注意:我只粘贴了 Perl 脚本的一部分,因为它很长;它应该是一个独立的脚本。

【问题讨论】:

  • 这东西是史前的,只有真正与现代 Perl 有共同的名字。简而言之,不要再使用它了。今天有更好的事情。如果您只是想为您的客户收集表单数据并且您不了解编程,请考虑使用Google Forms
  • 我无法使用 Google 表单;它们不安全,也不符合 HIPAA。
  • “如何使输出类似于普通电子邮件而不仅仅是列表”是什么意思?

标签: html forms perl email cgi


【解决方案1】:

您的问题的标题是“Perl 脚本未正确处理 html 表单”。我不确定那是什么意思。 formmail 以何种方式无法正确处理表单?它正在获取您的所有表单输入并发送包含所有信息的电子邮件。这就是它应该做的。它完全按预期工作。说它不能正常工作是不正确的。

正如 simbabque 在他的评论中所说,这东西真的是古董,不应该再使用了。我作为启动 nms 项目的人发言。它真的只是仍然存在,否则会有人们会被马特的剧本吸引回来的危险(更糟糕的是!)

nms 程序的初衷是他们复制了马特的脚本所做的事情。所以,是的,Formmail 会生成一个未格式化的输入列表。这就是当时的情况。我不太确定为什么有人会需要其他东西。

如果您真的想要一个 15 年前的 CGI 程序的格式化输出,那么请查看 nms (http://nms-cgi.sourceforge.net/scripts.shtml) 的 TFMail 程序,但实际上,现在有更好的方法来做到这一点。

【讨论】:

  • 那么我会使用其他脚本吗?像 PHP 脚本?
  • 好吧,您还没有解释 FormMail 的输出有什么问题。你到底在找什么?而且,正如我上面所说,您想要的很可能可以通过 TFMail 完成。
猜你喜欢
  • 2015-09-12
  • 2012-11-06
  • 2014-02-15
  • 2015-09-11
  • 1970-01-01
  • 2014-10-27
  • 2014-09-14
  • 2023-04-04
  • 2015-04-12
相关资源
最近更新 更多