----- Original Message -----
From: Matt Williams <[EMAIL PROTECTED]>
To: Boclair <[EMAIL PROTECTED]>; <[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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to