Question

I'm using formmail.pl to handle a form I'm using on my site. There are several fields which are sent to the script including name, email, phone and some text in a text area.

As it stands, the successful submission prints the phone and textarea data correctly but doesn't print the name and email which were entered. In the email it sends the name and email in the 'from' header and as with the success page only shows the phone and textarea data are shown in the email body.

I would like to show all data in both cases however I can't seem to find the section of code that handles this. I'd post up the formmail.pl script except its over 3000 lines of code so I'll just post the places I think are responsible and hopefully somebody can point me in the right direction. I'm fairly new to Perl and its a bit overwhelming reading and understanding a script of this size.

sub success_page {
  my ($self, $date) = @_;

  if ($self->{FormConfig}{'redirect'}) {
    print $self->cgi_object->redirect( $self->{FormConfig}{'redirect'} );
  }
  elsif ( $self->{CFG}{'no_content'}) {
    print $self->cgi_object->header(Status => 204);
  }
  else {
    $self->output_cgi_html_header;
    $self->success_page_html_preamble($date);
    $self->success_page_fields;
    $self->success_page_footer;
  }
}

sub success_page_html_preamble {
  my ($self, $date) = @_;

  my $title = $self->escape_html( $self->{FormConfig}{'title'} || 'Success' );
  my $torecipient = 'to ' . $self->escape_html($self->{FormConfig}{'recipient'});
  $torecipient = '' if $self->{Hide_Recipient};
  my $attr = $self->body_attributes;

  print <<END;
    <head>
    <title>$title</title>
  END

  $self->output_style_element;

  print <<END;
    <link type="text/css" href="css/stylesheet.css" rel="stylesheet" /></script>
    </head>

<body>

    <p>Below is what you submitted $torecipient on $date</p>
  END
}

sub success_page_fields {
  my ($self) = @_;

  foreach my $f (@{ $self->{Field_Order} }) {
    my $val = (defined $self->{Form}{$f} ? $self->{Form}{$f} : '');
    $self->success_page_field( $self->escape_html($f), $self->escape_html($val) );
  }
}


sub success_page_field {
  my ($self, $name, $value) = @_;
  print "<p><b>$name:</b> $value</p>\n";
}

Okay that's getting a bit long. That stuff is mostly for the success page and not much to do with the email side of things but maybe if somebody can find what I need there I can apply it to the email section also.

If any further information is needed let me know

Thanks in Advance

Was it helpful?

Solution

I haven't really used NMS FormMail myself, but looking at the source, it seems that you should be able to achieve something like what you want by setting the following extra configuration options:

$more_config{include_config_email} = 1;
$more_config{include_config_realname} = 1;

This should cause FormMail.pl to treat the email and realname fields as normal form fields, in addition to their special meaning.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top