Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001041

Re: [PHP-DB] Forms : Validating user input is integer From: boclair (boclair <email protected>)
Date: 04/05/01

----- Original Message -----
From: Matt Williams <matt <email protected>>
To: Boclair <boclair <email protected>>; <php-db <email protected>>
Sent: Thursday, April 05, 2001 11:28 PM
Subject: RE: [PHP-DB] Forms : Validating user input is integer

The line should read, and as I tested it,
> >
> > elseif (eregi("[a-zA-Z]",$num)) { }
> >
> > Do you see any problem with this?
>
> Yes, same thing it will accept other character like !*- etc...
>
> try
>
> if(!eregi("^[0-9]+[0-9]*$",$num)
>

> file://error
> }

You are right again. Stops all further processing of the inserted
variable if it is not entirely composed of digits.

It did not cross my mind to check for ! (shift 1) and similar entry
errors.

Once again, thanks.

Tim

So here is the final working script

<?
if ((@!$submit) || empty($num) )
     {
     echo "<div align='center'><span class='note'>No entry was
made</span></div>";
    include "get_id.php";
     }
if(!eregi("^[0-9]+[0-9]*$",$num))
     {
      echo "<div align='center'><span class='note'>The ID should have
been a number.</span></div>";
      include "get_id.php";
    }
else
    {
       include "do_form.php";
     }
?>

Tim

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>