Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [HELP] code modification

Reply
Thread Tools

[HELP] code modification

 
 
Paul Sellis
Guest
Posts: n/a
 
      12-16-2003

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";
 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      12-16-2003
Paul Sellis <(E-Mail Removed)> wrote in newsaul.sellis-
http://www.velocityreviews.com/forums/(E-Mail Removed):

>
> 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. Sinan Unur
(E-Mail Removed)
Remove dashes for address
Spam bait: (E-Mail Removed)
 
Reply With Quote
 
 
 
 
Paul Sellis
Guest
Posts: n/a
 
      12-17-2003
In article (Dans l'article)
<Xns94538351D90AAasu1cornelledu@132.236.56.8>,
"A. Sinan Unur" <(E-Mail Removed)> wrote (écrivait)*:
> Why don't you ask the author of the script?


Can't find him !
Wrote in 1997, no nore support I thinkŠ
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      12-17-2003
Paul Sellis <(E-Mail Removed)> wrote in newsaul.sellis-
(E-Mail Removed):

> In article (Dans l'article)
> <Xns94538351D90AAasu1cornelledu@132.236.56.8>,
> "A. Sinan Unur" <(E-Mail Removed)> wrote (écrivait)*:
>> Why don't you ask the author of the script?

>
> 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.



--
A. Sinan Unur
(E-Mail Removed)
Remove dashes for address
Spam bait: (E-Mail Removed)
 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      12-17-2003

"Paul Sellis" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
>
>
> 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 !
>


It would require more work than it's worth to fix such a hideous script.
You're better off using something newer:

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

Matt


 
Reply With Quote
 
Paul Sellis
Guest
Posts: n/a
 
      12-17-2003
In article (Dans l'article)
<Xns9453CA1F4EF5Fasu1cornelledu@132.236.56.8>,
"A. Sinan Unur" <(E-Mail Removed)> wrote (écrivait)*:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OT? My First Working Modification of C++ Example Code, under QT. :-D Rich Grise C++ 7 02-04-2006 04:19 PM
Online Modification of Python Code malv Python 10 09-06-2005 08:19 AM
DNS Reply Modification (doctoring) intermittently failing Dav0 Cisco 1 01-28-2005 07:00 PM
HTML [meta] code dynamic modification Maziar Aflatoun ASP .Net 1 08-07-2004 11:15 PM
Modification of Duty Cycle - Possible? Drew VHDL 2 08-02-2004 06:54 PM



Advertisments