Ask a Question related to PERL Beginners, Design and Development.
-
Jeff 'Japhy' Pinyan #1
Re: Is it a good idea-verifing incoming info
On Aug 17, awards said:
To answer your subject line, YES, it is a good idea to verifying the data>I have many forms, and basically I just need to receive either a number
>or characters or both. this is how I check
a user sends you is what you expect.
$value and $name should be declare inside the loop, since that's the>my ($value,%result,$name);
extent of their scope (as far as this code shows).
Why are you bothering to do anything to the NAME of the field? You>foreach (param){
> $name = $_;
> $name =~ s/\s$//;##take the space at the end
> $name =~ s/[^a-zA-Z0-9]//g;##all none character is change into nothing
created the names of the form fields (right?), and besides, you don't end
up using $name.
Why do you remove the space at the end if you're going to be removing all> $value = param($_);
> $value =~ s/\s$//;## take the space at then end
> $value =~ s/[^a-zA-Z0-9]//g;##all none character is change into nothing
non-letters-and-numbers anyway? A space would be deleted anyway.
Finally, why are you using a hash? Why not just store the values back> $result{$_}=$value;
>}
into param()? If you're dealing with a form that has checkboxes, or
multiple fields with the same name, you'll lose some data your way.
for (param) {
my @values = param($_);
tr/a-zA-Z0-9//cd for @values; # a faster way
param($_, @values); # this SETS the values of the param to @values
}
--
Jeff "japhy" Pinyan [email]japhy@pobox.com[/email] [url]http://www.pobox.com/~japhy/[/url]
RPI Acacia brother #734 [url]http://www.perlmonks.org/[/url] [url]http://www.cpan.org/[/url]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Jeff 'Japhy' Pinyan Guest
-
How to avoid the prompt when verifing signature?
I sign the doc with my cert. The cert is not trusted by Acrobat/Reader itself so when i try to verify the signature Acrobat/Reader will prompt the... -
Xcart no good, support no good, need good shopping cart!!!
I need a good quality php shopping cart to port to my site, allowing software downloads and book sales. Integrating ease is really important and... -
Remove OS X System Helvetica TTF -- really a good idea?
Somewhere I saw a recommendation to make IllustratorCS work more reliably by removing the Helvetica TTF files from the OS X System and installing... -
You have no idea how good you have it until...
Sympathy appreciated. Here;s just a sample, off the top of my head, of what works on the Mac, ut not on Windows. 1. Proportianal automatic... -
Sending a file with freeze is not a good idea...
Hi all, I'll try to make it very easy to understand, so if you want more details, just ask. I have a system composed of some perl scripts... -
Awards #2
Re: Is it a good idea-verifing incoming info
Hi,
thank you
We ll you ask----I'm using a hash because the actual code is> Finally, why are you using a hash? Why not just store the values back
> into param()? If you're dealing with a form that has checkboxes, or
> multiple fields with the same name, you'll lose some data your way.
%ACTION=parameters();
sub parameters{
###THE CODE TO VERIFY
return %result;
}
personnally I find it easier to type ACTION than param. I make less typo
typing ACTION than param because it is hard for me to get the 'm'
----I didn't know that perl removed the end space Good news and I learn> Why do you remove the space at the end if you're going to be removing all
> non-letters-and-numbers anyway? A space would be deleted anyway.
something new :-).
these are my toughts:
You said:Well you are right, I tought Before maybing someone will at code to the name> Why are you bothering to do anything to the NAME of the field? You
> created the names of the form fields (right?), and besides, you don't end
> up using $name.
to hack into the script.
But think about it again, I'm always doing $ACTION{name} some if he/she puts
a code then it won't have any effect
at least I hope.
And Thank you about this
'tr/a-zA-Z0-9//cd for @values'
I whish I new it before.
thanx Again
Anthony
"Jeff 'Japhy' Pinyan" <japhy@perlmonk.org> wrote in message
news:Pine.LNX.4.44.0308170920180.9168-100000@perlmonk.org...nothing> On Aug 17, awards said:
>>> >I have many forms, and basically I just need to receive either a number
> >or characters or both. this is how I check
> To answer your subject line, YES, it is a good idea to verifying the data
> a user sends you is what you expect.
>>> >my ($value,%result,$name);
> $value and $name should be declare inside the loop, since that's the
> extent of their scope (as far as this code shows).
>> >foreach (param){
> > $name = $_;
> > $name =~ s/\s$//;##take the space at the end
> > $name =~ s/[^a-zA-Z0-9]//g;##all none character is change intonothing>
> Why are you bothering to do anything to the NAME of the field? You
> created the names of the form fields (right?), and besides, you don't end
> up using $name.
>> > $value = param($_);
> > $value =~ s/\s$//;## take the space at then end
> > $value =~ s/[^a-zA-Z0-9]//g;##all none character is change into>
> Why do you remove the space at the end if you're going to be removing all
> non-letters-and-numbers anyway? A space would be deleted anyway.
>>> > $result{$_}=$value;
> >}
> Finally, why are you using a hash? Why not just store the values back
> into param()? If you're dealing with a form that has checkboxes, or
> multiple fields with the same name, you'll lose some data your way.
>
> for (param) {
> my @values = param($_);
> tr/a-zA-Z0-9//cd for @values; # a faster way
> param($_, @values); # this SETS the values of the param to @values
> }
>
> --
> Jeff "japhy" Pinyan [email]japhy@pobox.com[/email] [url]http://www.pobox.com/~japhy/[/url]
> RPI Acacia brother #734 [url]http://www.perlmonks.org/[/url] [url]http://www.cpan.org/[/url]
> <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
> [ I'm looking for programming work. If you like my work, let me know. ]
>
Awards Guest



Reply With Quote

