Help with form validation!

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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Help with form validation!

Post by onion2k »

In PHP everything coming from the user is a string, so it'll always return true if you check it with is_string(). That isn't a problem though, because PHP variables are loosely typed - PHP will treat the value as number if it's a number when you use a mathematical function on it. So, in your case, so long as is_numeric() returns true you're fine. You don't need to check if it's a string or not.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Help with form validation!

Post by jackpf »

You should use isset() to make sure the post variables exists before checking if they're null.
Post Reply