Click to See Complete Forum and Search --> : Help


tarotman
08-23-2004, 03:00 AM
Hi I have this script that is pretty long...

On the bottom it says:

$vdeck->send_email({ -to => $to,
-from => $to,
-cc => [split ',', $cc],
-bcc => [split ',', $bcc],
-subject => "Feedback: from $form_meta->[2]",
-message => $message
});

If I change the "-subject" line everything goes to hell. I don't want it to say from our web site just a written line no code. Is this possible? Do I need to take anything else off?

Tahnk you


#!/usr/bin/perl
############################################
#
# forms.cgi - form processor for forms created though admin panel
#
# (c) 2003 vDeck.com
#
############################################
use strict;
use warnings;
use CGI;
use vDeckPublic;
use DBI;

use constant F_ID => 0;
use constant F_FORMID => 1;
use constant F_FIELDNAME => 2;
use constant F_FIELD_TYPE => 3;
use constant F_FIELD_DEFAULT => 4;
use constant F_FIELD_TAINTCHECK => 5; # for future use
use constant F_FIELD_RANK => 6;

my $q = CGI->new();

# find homedir
my $homedir = '';
$ENV{DOCUMENT_ROOT} =~ m|(/home/[\w\-]+)| and $homedir = $1;

# print "Content-type: text/plain\n\n--$homedir--"; exit(0);

my $vdeck = vDeckPublic->new({ -db => "DBI:CSV:f_dir=$homedir/.panel/data/;csv_eol=\n;",
-user => '',
-pass => '' });

$homedir || $vdeck->fatal_error("Can't determine home directory");

my $form_id='';

my %var = $q->Vars();
foreach my $f_name(keys %var){
if($f_name =~ /^_(\w+)formid$/){
$q->param($f_name) =~ /(\d+)/ and $form_id = $1;
last;
}
}

$form_id || $vdeck->fatal_error("Invalid form ID. Please check your SSI code!");

# WHERE form_id='$form_id'
my $form_fields = $vdeck->db_query("SELECT * FROM form_fields WHERE form_id='$form_id'");
defined $form_fields->[0] or $vdeck->fatal_error("No form fields defined - please check your form design.");

my %form_field = ();

for (@{$form_fields}) {
my $field_name = $_->[2];
$field_name =~ s/\W/_/g;
defined ( $q->param($field_name) ) and $form_field{$field_name} = $q->param($field_name);
}

# everything OK, so send e-mail
my $form_meta = $vdeck->db_query("SELECT * FROM form_meta WHERE id='$form_id'",'rowarray');
defined $form_meta->[0] or $vdeck->ssi_error("Invalid form ID. Please check your SSI code!");

my $to = $form_meta->[3];
my $cc = $form_meta->[4];
my $bcc = $form_meta->[5];
my $message = $form_meta->[6];
my $redirect = $form_meta->[7] || '/v-web/forms/thanks.htm';

while ($message =~ /\[% (\S+) %\]/s) {
my $attr = $1;
$message =~ s/\[% $attr %\]/$form_field{$attr}/gs;
}

$vdeck->send_email({ -to => $to,
-from => $to,
-cc => [split ',', $cc],
-bcc => [split ',', $bcc],
-subject => "Feedback: from $form_meta->[2]",
-message => $message
});

print $q->redirect($redirect);
exit(0);

silent11
08-23-2004, 08:23 AM
Show us what you are attempting to set as the subject line.

tarotman
08-23-2004, 12:59 PM
Hi

"A customer have sumbitted information"

CyCo
08-23-2004, 02:01 PM
So, tarotman, are you telling us that the following fails?

-subject => "A customer have sumbitted information",

tarotman
08-24-2004, 12:54 AM
Yes, major crash

silent11
08-25-2004, 10:08 AM
put this line up at the top of your script with the other use statements.

use CGI::Carp qw(fatalsToBrowser);

and tell us what the error is.

-Will