input validation

Discussion in 'Perl Misc' started by Alexandre Jaquet, Sep 27, 2005.

  1. Hi,

    I've a trouble when I parse web page input, I want to accept only
    alphanumeric char (with accent) and ignore it when the datas is equal
    is to "Toutes les cat├ęgories"

    I do the following :

    local our $category = $query->param("categories");
    $category =~ s/[^\w]//g;

    local our $test = $SERVER{'all_categories'};
    if ($category ne $test) {
    $add .= " AND ref_categorie = id_categorie AND categorie_$lang.nom =
    '$category'";
    $from .= "article, categorie_$lang,statut_$lang";
    }else {
    $add .= "AND article.ref_statut = id_statut AND ref_statut = '3' AND
    ref_categorie = id_categorie ";
    $from .= "article,statut_$lang,categorie_$lang"
    }
    but I the following part "$add .= " AND ref_categorie = id_categorie AND
    categorie_$lang.nom = " is still executed

    any help

    many thanks
     
    Alexandre Jaquet, Sep 27, 2005
    #1
    1. Advertising

  2. Alexandre Jaquet

    Paul Lalli Guest

    Alexandre Jaquet wrote:
    > I've a trouble when I parse web page input, I want to accept only
    > alphanumeric char (with accent) and ignore it when the datas is equal
    > is to "Toutes les cat├ęgories"
    >
    > I do the following :
    >
    > local our $category = $query->param("categories");
    > $category =~ s/[^\w]//g;


    You know that [^\w] is more quickly written as \W, right?

    > local our $test = $SERVER{'all_categories'};
    > if ($category ne $test) {
    > $add .= " AND ref_categorie = id_categorie AND categorie_$lang.nom =
    > '$category'";
    > $from .= "article, categorie_$lang,statut_$lang";
    > }else {
    > $add .= "AND article.ref_statut = id_statut AND ref_statut = '3' AND
    > ref_categorie = id_categorie ";
    > $from .= "article,statut_$lang,categorie_$lang"
    > }
    > but I the following part "$add .= " AND ref_categorie = id_categorie AND
    > categorie_$lang.nom = " is still executed


    .... and? Is that not what you want? You haven't shown us what *any*
    of these variables are. How are we supposed to know how or why this
    isn't the "correct" behavior?

    Please, include some debugging statements that show us the values of
    $category before the s///, $category after the s///, and $test. Then
    post the results of that debugging as a followup.

    Paul Lalli
     
    Paul Lalli, Sep 27, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Mackay
    Replies:
    0
    Views:
    2,698
    Colin Mackay
    Jun 25, 2003
  2. Libs
    Replies:
    0
    Views:
    1,508
  3. Colin Basterfield

    Web form validation vs object validation

    Colin Basterfield, Nov 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    430
    Tommy
    Nov 29, 2003
  4. Matt
    Replies:
    14
    Views:
    4,114
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  5. Lucas Tam
    Replies:
    2
    Views:
    1,120
    Lucas Tam
    Feb 26, 2004
Loading...

Share This Page