Is it a good idea-verifing incoming info

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Re: Is it a good idea-verifing incoming info

    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 into nothing
    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 nothing
    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. ]

    Jeff 'Japhy' Pinyan Guest

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: Is it a good idea-verifing incoming info

    Hi,


    thank you

    We ll you ask
    > 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.
    ----I'm using a hash because the actual code is
    %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'

    > 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.
    ----I didn't know that perl removed the end space Good news and I learn
    something new :-).

    these are my toughts:
    You said:
    > 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.
    Well you are right, I tought Before maybing someone will at code to the 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...
    > 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 into
    nothing
    >
    > 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
    nothing
    >
    > 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139