Loading ...
Sorry, an error occurred while loading the content.

Form processing...

Expand Messages
  • gordon stewart
    Hi there - is there any process to validate input ? Ive got a form, but i only want to put a NUMBER in it - no letters or non numeric (I will allow commas & a
    Message 1 of 7 , Aug 7, 2001
    • 0 Attachment
      Hi there - is there any process to validate input ?

      Ive got a form, but i only want to put a NUMBER in it
      - no letters or non numeric (I will allow commas & a
      dot (eg 324,987.98 )

      But i'll just remove those commas & dots before-hand.

      How can i tell / Check if a non-numeric entity has
      been entered ?

      Gordon.


      =====
      G. Stewart
      New Zealand chat & Discussion group email
      new_zealand-help@yahoogroups.com for details.
    • Jenda Krynicky
      ... Learn regular expressions! ... $foo = $cgi- param( foo ); if ($foo !~ /^ d*$/) { die foo contains some non-numeric characters !!! n ; } ... $foo =~
      Message 2 of 7 , Aug 7, 2001
      • 0 Attachment
        > Hi there - is there any process to validate input ?

        Learn regular expressions!

        > Ive got a form, but i only want to put a NUMBER in it
        > - no letters or non numeric (I will allow commas & a
        > dot (eg 324,987.98 )

        $foo = $cgi->param('foo');

        if ($foo !~ /^\d*$/) {
        die "foo contains some non-numeric characters !!!\n";
        }

        > But i'll just remove those commas & dots before-hand.

        $foo =~ tr/,.//d;

        but keep in mind that the dot is meaningfull so you probably want :

        $foo =~ tr/,//d;
        if ($foo !~ /^\d*(\.\d+)?$/) {
        die "foo contains some non-numeric characters !!!\n";
        }

        Jenda

        == Jenda@... == http://Jenda.Krynicky.cz ==
        : What do people think?
        What, do people think? :-)
        -- Larry Wall in <199808071736.KAA12738@...>
      • Damien Carbery
        I highly recommend using Javascript on the client (browser) side to validate data before it gets to your perl code. You won t remove your checks from your perl
        Message 3 of 7 , Aug 7, 2001
        • 0 Attachment
          I highly recommend using Javascript on the client (browser) side to
          validate data before it gets to your perl code. You won't remove your
          checks from your perl code but the incoming data should be quite
          clean.
          If a user makes a mistake the Javascript code will tell them, not a
          response from a CGI which could take a while.

          --- In perl-beginner@y..., "Jenda Krynicky" <Jenda@K...> wrote:
          > > Hi there - is there any process to validate input ?
          >
          > Learn regular expressions!
          >
          > > Ive got a form, but i only want to put a NUMBER in it
          > > - no letters or non numeric (I will allow commas & a
          > > dot (eg 324,987.98 )
          >
          > $foo = $cgi->param('foo');
          >
          > if ($foo !~ /^\d*$/) {
          > die "foo contains some non-numeric characters !!!\n";
          > }
          >
          > > But i'll just remove those commas & dots before-hand.
          >
          > $foo =~ tr/,.//d;
          >
          > but keep in mind that the dot is meaningfull so you probably want :
          >
          > $foo =~ tr/,//d;
          > if ($foo !~ /^\d*(\.\d+)?$/) {
          > die "foo contains some non-numeric characters !!!\n";
          > }
          >
          > Jenda
          >
          > == Jenda@K... == http://Jenda.Krynicky.cz ==
          > : What do people think?
          > What, do people think? :-)
          > -- Larry Wall in <199808071736.KAA12738@w...>
        • Qing Hua
          $START_DT=TO_DATE( 2001/07/24-19:18:26 , YYYY/MM/DD-HH24:MI:SS ); To insert this and other data into database I did: $insert= INSERT INTO test_db (START_DT,
          Message 4 of 7 , Aug 7, 2001
          • 0 Attachment
            $START_DT=TO_DATE('2001/07/24-19:18:26','YYYY/MM/DD-HH24:MI:SS');

            To insert this and other data into database I did:

            $insert="
            INSERT INTO test_db
            (START_DT, AA, BB)
            VALUES
            (?,?,?)
            ";

            $sth=$dbh->prepare($insert);
            $sth->execute($START_DT,$AA,$BB);

            The error message I got is:
            DBD::Oracle::st execute failed: ORA-01843: not a valid
            month (DBD ERROR: OCIStmtExecute)

            What did I do wrong?

            For testing, I did:
            $insert = "
            INSERT INTO test_db
            (START_DT,AA,BB)
            VALUES
            (TO_DATE('2001/07/24-19:18:26','YYYY/MM/DD-HH24:MI:SS'),
            'aa', 'bb')
            ";
            $dbh->do($insert);

            This worked fine.

            Thanks for the help!

            __________________________________________________
            Do You Yahoo!?
            Make international calls for as low as $.04/minute with Yahoo! Messenger
            http://phonecard.yahoo.com/
          • Jenda Krynicky
            ... The last sentence is important! Do NOT rely on the JavaScript validation. The user could have JavaScript turned off, or may be trying to cheat to you. ...
            Message 5 of 7 , Aug 8, 2001
            • 0 Attachment
              > I highly recommend using Javascript on the client (browser) side to
              > validate data before it gets to your perl code. You won't remove your
              > checks from your perl code but the incoming data should be quite
              > clean.

              The last sentence is important! Do NOT rely on the JavaScript
              validation. The user could have JavaScript turned off, or may be
              trying to cheat to you.

              > If a user makes a mistake the Javascript code will tell them,
              > not a response from a CGI which could take a while.

              And ... here it comes ... you may use regular expressions in
              JavaScript (not sure exactly what version of browsers required.
              MSIE 5 and Opera 5.11 do support it.)

              Jenda

              == Jenda@... == http://Jenda.Krynicky.cz ==
              : What do people think?
              What, do people think? :-)
              -- Larry Wall in <199808071736.KAA12738@...>
            • erik.tank@bpxinternet.com
              I would caution the use of Javascript or anything else that relies on client side processing. If you are using it you are placing your faith in that the
              Message 6 of 7 , Aug 8, 2001
              • 0 Attachment
                I would caution the use of Javascript or anything else that relies on client
                side processing. If you are using it you are placing your faith in that the
                client software is working correctly and doing what you want it to. In
                other words ... You really don't know how it is going to act for everyone
                out there and there is really no way to test it so that it will work for
                everyone.

                So weigh the pros and cons of using Javascript carefully.

                Erik Tank
                602-817-4705
                erik.tank@...


                -----Original Message-----
                From: Jenda Krynicky [mailto:Jenda@...]
                Sent: Wednesday, August 08, 2001 5:56 AM
                To: Damien Carbery; perl-beginner@yahoogroups.com
                Subject: Re: [PBML] Form processing...


                > I highly recommend using Javascript on the client (browser) side to
                > validate data before it gets to your perl code. You won't remove your
                > checks from your perl code but the incoming data should be quite
                > clean.

                The last sentence is important! Do NOT rely on the JavaScript
                validation. The user could have JavaScript turned off, or may be
                trying to cheat to you.

                > If a user makes a mistake the Javascript code will tell them,
                > not a response from a CGI which could take a while.

                And ... here it comes ... you may use regular expressions in
                JavaScript (not sure exactly what version of browsers required.
                MSIE 5 and Opera 5.11 do support it.)

                Jenda

                == Jenda@... == http://Jenda.Krynicky.cz ==
                : What do people think?
                What, do people think? :-)
                -- Larry Wall in <199808071736.KAA12738@...>




                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
              • Qing Hua
                I ve got the answer for this one. We cannot bind an SQL expression to a placeholder. We can only bind a simple value. If I do the following, it works.
                Message 7 of 7 , Aug 8, 2001
                • 0 Attachment
                  I've got the answer for this one.


                  We cannot bind an SQL expression to a placeholder. We
                  can only bind a
                  simple value.

                  If I do the following, it works.

                  $start_date = '2001/07/24-19:18:26';

                  $insert = <<"EndOfSQL";
                  INSERT INTO test_db
                  (START_DT, AA, BB)
                  VALUES
                  (TO_DATE(?, 'YYYY/MM/DD-HH24:MI:SS'), ?, ?)
                  EndOfSQL

                  $sth = $dbh->prepare($insert);

                  $sth->execute($start_date, $aa, $bb);




                  --- Qing Hua <two_waytickets@...> wrote:
                  >
                  $START_DT=TO_DATE('2001/07/24-19:18:26','YYYY/MM/DD-HH24:MI:SS');
                  >
                  > To insert this and other data into database I did:
                  >
                  > $insert="
                  > INSERT INTO test_db
                  > (START_DT, AA, BB)
                  > VALUES
                  > (?,?,?)
                  > ";
                  >
                  > $sth=$dbh->prepare($insert);
                  > $sth->execute($START_DT,$AA,$BB);
                  >
                  > The error message I got is:
                  > DBD::Oracle::st execute failed: ORA-01843: not a
                  > valid
                  > month (DBD ERROR: OCIStmtExecute)
                  >
                  > What did I do wrong?
                  >
                  > For testing, I did:
                  > $insert = "
                  > INSERT INTO test_db
                  > (START_DT,AA,BB)
                  > VALUES
                  >
                  (TO_DATE('2001/07/24-19:18:26','YYYY/MM/DD-HH24:MI:SS'),
                  > 'aa', 'bb')
                  > ";
                  > $dbh->do($insert);
                  >
                  > This worked fine.
                  >
                  > Thanks for the help!
                  >
                  > __________________________________________________
                  > Do You Yahoo!?
                  > Make international calls for as low as $.04/minute
                  > with Yahoo! Messenger
                  > http://phonecard.yahoo.com/
                  >


                  __________________________________________________
                  Do You Yahoo!?
                  Make international calls for as low as $.04/minute with Yahoo! Messenger
                  http://phonecard.yahoo.com/
                Your message has been successfully submitted and would be delivered to recipients shortly.