Pls, is there are any i could validate the input into a form , say user should only enter numerals rather that string xters from PHP
| SitePoint Sponsor |
Pls, is there are any i could validate the input into a form , say user should only enter numerals rather that string xters from PHP





You can use is_numeric (http://uk.php.net/is_numeric) to check if a value is numeric or not. For more complicated form validation, I.e checking a valid email address you would probably do so using regular expressions.
start with http://php.net/manual/en/function.is-numeric.php and go from there....
Promote your site at Site Review Blog
SEO Tools and Articles || Short URL || Temporary EMail
Image Hosting || Resize Images Online ||Adult Jokes
To get ease yourself from all the pain involved in form validation, use QuickForm package of PEAR. Yes, it might be a bit difficult to grasp to begin with, but as you do it for sometime it’s breeze.





Until you come to a situation where you cant use Pear, then all of a sudden you dont know how to validate input. For someone, who is obviously fairly new to PHP it would be more beneficial to learn how to validate input alone.Originally Posted by Kailash Badu
It hardly happens, I suppose. Even when you use Pear, you easily know how exactly the validation is working. All the rules are written under Rule class, which simple uses general preg_match() against different regex values. In case you don’t have pear, you can easily rewrite those function inside your own form validation page. I have found it easier then I expected.Until you come to a situation where you cant use Pear, then all of a sudden you dont know how to validate input
Bookmarks