Hi,
I've made a form for user-Adds. I want to verify, that one textfield is checked for "not empty" and one other checked for- it has to be an int oder double.
e.g.
if (empty($_POST[C]))
{
echo "here's the output, when if ist TRUE<br>";
}
I've done all with POST and everything ist fine with empty, but how can a form-textfield be checked for, that the Value has to be a Number?
Can I make this wir is_int oder is_double somewhere in the IF-Block. Some like:
if ( (empty($_POST[C])) && (is_integer($_POST[A])) )
.... bla
?????
Jan
Verification in Forms
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You can do this:
Don't forget the quotes around the array elements ($_POST['C'] instead of $_POST[C]) for why see this page:
http://www.php.net/manual/en/language.t ... rray.donts
Also you would use is_numeric() instead of is_integer() because:
Code: Select all
if (empty($_POST['C']) && is_numeric($_POST['A'])) {
// blah
}http://www.php.net/manual/en/language.t ... rray.donts
Also you would use is_numeric() instead of is_integer() because:
MacPHP Manual - is_int() wrote:Note: To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
you're Legends :)
thx for that fast help.
Jan
Jan