validating input from forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

validating input from forms

Post by sh33p1985 »

quite simply for tieing up those loose ends of my form processing, id like to validate that some of the fields which require interger input (i.e. a number) are actually an integer and not a string so i can catch and handle the error.

e.g.
StockLevel = 100 (should be the correct input)
StockLevel = "fubar" (should throw an error)

something similar for prices which should be entered in xx.xx format.

im thinking regular expressions here, am i right?
User avatar
theYinYeti
Forum Newbie
Posts: 15
Joined: Thu Oct 26, 2006 3:33 pm
Location: France

Post by theYinYeti »

Wouldn't PHP's is_xxx functions work in this case? eg: is_integer($var)

Yves.
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

Post by sh33p1985 »

super! thanks:)
Post Reply