> if(ereg("^[0-9]{7,9}$", $_REQUEST["icqnumber"])) { > >> print("a-okay!"); > >> } else { > >> print("error msg"); > >> }
Although I'm not too familiar with regexp I'd say the code validates because the icq number you are providing actually confimrs to the pattern. The first seven to nine digits contain only numbers so the pattern is true. Th ce pattern does not check the length of your provided string. If I'm correct than "123456789 This is a test" will also proof to be correct. So you have to do two things first check the whole argument for digits like ereg('^[0-9]{'.strlen($_REQUEST['icqnumber']).'}', $_REQUEST['icqnumber']) and check length separatly. (U can also use [[:digit:]]) Or use the code as mentioned before. In your place I would not assume anything about the length of the icq number. Hope that helps Stefan P.S.: Please correct me if I'm wrong with the above!!!!