[HELP] code modification

P

Paul Sellis

I need your help :

I am newbie in coding. I use a free scrit "form_processor.pl 1.0" to
make forms from my html pages. I am satisfied with it.

BUT, I have always a problem with syntax in Javascripts (and now in
FlashŠ) because it begins with a digit and a right parenthesis.
i.e.
<input type="TEXT" name="01)name" value="1">
The digit serves to order the fields in the results received.


Is it possible to use alphabetical order of letters instead ?
Like this for example :
<input type="TEXT" name="A-name" value="10">
<input type="TEXT" name="B-name" value="20">
<input type="TEXT" name="BB-name" value="25">
<input type="TEXT" name="C-name" value="30">
<input type="TEXT" name="D-name" value="40">

Thanks for your help !

I think that :
d*\)
must say something like "any digit and a right parenthesis". Et I should
modify (at least) this part of code. But folks I need your help !

Thanks
Paul.


€ The code :



#Option No. 1
$email_admin = 1; #1 is on; 0 if off;

#Option No. 2
$write_form_info = 1; #1 is on; 0 is off;
#Path of file to write form data to. Must be read/writeable
$form_info_path = "list.txt";

#Option No. 3
$email_datafile = 0; #1 is on; 0 is off;
#Path to email addresses datafile
$email_datafile_path = "emails.txt";

#Option No. 4
$send_email_to_user = 0; #1 is on; 0 is off;
#Path of text file to be sent to user
$feedback_response_path = "feedback_response.txt";

#Option No. 5
$include_field_name = 0; #1 is on; 0 if off;

#Subject of email sent to user
$email_subject = "xxxxxxxx";

#Path to sendmail
$mailprog = "/usr/sbin/sendmail";

$date_command = "/usr/bin/date";

#You should not need to change anything beyond this point

$date = `$date_command +"%D"`;

#Go through the required fields and send to user an error message if
field is empty
while (($key, $value) = each %input) {
if ($key =~ /required-/ && $value eq "") {
$key =~ s/^\d*\)*required\-*//g;
print &PrintHeader;
print "Please use the back button on your browser to ";
print "enter the required information and submit the form again. Thank
you.";
exit;
}
}

#Take all the fields that begin with a number, sort them by number and
put them into #the sortedkeys array
foreach $key (sort(keys(%input))) {
if ($key =~ /user_email/) {
$user_email = "$input{$key}";
$user_email =~ s/^\d*\)\s*//;
$user_email =~ s/required-//;
}
unless ($key =~ /^\d+/) {
next;
}
push (@sortedkeys, "$key|$input{$key}");
}

#Send email to admin if selected
if ($email_admin == 1) {
&email_admin;
}
#Send text file to user if selected
if ($send_email_to_user == 1) {
&send_info;
}
#Write form data to file if selected
if ($write_form_info == 1) {
&write_form_info;
}
#Write email addresses to datafile if selected
if ($email_datafile == 1) {
&write_email_datafile;
}

sub write_email_datafile {
open (EMAIL, ">>$email_datafile_path") || die ("I am sorry, but I was
unable to open the file $email_datafile_path");
print EMAIL "$user_email\n";
}

sub write_form_info {
open (FORM, ">>$form_info_path") || die ("I am sorry, but I was unable
to open the file $form_info_path");
foreach $sortedkeys (@sortedkeys) {
$sortedkeys =~ s/^\d*\)\s*//;
$sortedkeys =~ s/required-//;
($name, $answer) = split (/\|/, $sortedkeys);
print FORM "$name -- $answer\t";
}
print FORM "\n";
close (FORM);
}

sub send_info {
if ($user_email =~ /^[\w-.]+\@[\w-.]+$/) {
open (MAIL, "|$mailprog $user_email") || die "Can't open $mailprog!\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/html; charset=iso-8859-1\n";
print MAIL "To: $user_email\n";
print MAIL "From: $input{'admin'}\n";
print MAIL "Subject: $email_subject\n\n";
open (PAGE, "$feedback_response_path") || die ("I am sorry, but I was
unable to open the file $feedback_response_path.");
while (<PAGE>) {
print MAIL $_;
}
close (PAGE);
close (MAIL);
}
}

sub email_admin {
if ($input{'admin'} =~ /^[\w-.]+\@[\w-.]+$/) {
open (MAIL, "|$mailprog $input{'admin'}") || die "Can't open
$mailprog!\n";
print MAIL "To: $input{'admin'}\n";
print MAIL "From: $user_email\n";
print MAIL "Subject: $input{'subject'}\n\n";
foreach $sortedkeys (@sortedkeys) {
$sortedkeys =~ s/^\d*\)\s*//;
$sortedkeys =~ s/required-//;
($name, $answer) = split (/\|/, $sortedkeys);
if ($include_field_name == 1) {
print MAIL "$name -- $answer\n";
}
else {
print MAIL "$answer\n";
}
}
close (MAIL);
}
}

#Send them to the proper URL
print "Location: $input{'redirect'}\n\n";
 
A

A. Sinan Unur

I need your help :

I am newbie in coding. I use a free scrit "form_processor.pl 1.0" to
make forms from my html pages. I am satisfied with it.

Why don't you ask the author of the script?
 
A

A. Sinan Unur

Can't find him !
Wrote in 1997, no nore support I thinkŠ

Well, since your domain name include my name, here is some advice :) (What
does alussinan mean anyway?

You might want to dump this script and use nms formmail:

http://nms-cgi.sourceforge.net/

On the other hand, it looks like the script relies on the default behavior
of Perl's sort function:

If SUBNAME or BLOCK is omitted, "sort"s in standard string
comparison order.

Hence, you ought to be able to use the scheme you suggested without
modifying the code.

Also, I suspect this is not the full script. Where, for exampe, is %input
initialized? And where is PrintHeader defined?

Please realize that these are rhetorical questions. Frankly, I am not
interested in fixing this script, and I doubt anyone else is either.

Good luck.

Sinan.
 
P

Paul Sellis

A. Sinan Unur said:
Well, since your domain name include my name, here is some advice :) (What
does alussinan mean anyway?

a french server that filters spam


thanks for all your answers and advises
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top