I have form that post a number to my script

$number

I need to make sure $number is always a number between 1-10 digits long and does not contain a period so 123.45 would show up as 123

    If you want to validate it and either accept or reject it:

    if(ctype_digit($number) and $number strlen($number) <= 10)
    {
       // valid
    }
    else
    {
       // invalid
    }
    

    If you just want to convert, you could use the [man]round[/man] function.

      NogDog wrote:

      If you want to validate it and either accept or reject it:

      if(ctype_digit($number) and $number strlen($number) <= 10)
      {
         // valid
      }
      else
      {
         // invalid
      }
      

      If you just want to convert, you could use the [man]round[/man] function.

      this line gave me errors
      unexpected T_STRING

      if(ctype_digit($amount) and $amount strlen($amount) <= 10){
      

        Im trying this with the use of ! but it seems to always return
        ERROR: Whole dollar amounts only please

        if(!ctype_digit($amount)){
         $msg = "ERROR: Whole dollar amounts only please";
        $_SESSION['sess_msg'] = $msg;
        header("location: $SITE_PATH?p=account.money&r=$receiver");
        exit;
        } 
        
          jasondavis wrote:

          this line gave me errors
          unexpected T_STRING

          if(ctype_digit($amount) and $amount strlen($amount) <= 10){
          

          Sorry, I think I changed my mind in mid-stream of typing that line.

          if(ctype_digit($amount) and strlen($amount) <= 10)
          
            Write a Reply...