Page 1 of 1

Null value

Posted: Wed Jan 13, 2010 8:11 am
by mariolopes
How can i detect if a field is null? I try the is_nukk function but it seems doesn't work. Please review the following code:
<html>
<?php
if(!isset($_POST['Idade'])){
print "Valor zero";
}
if(is_null($_POST['Idade'])){
print "Tá branco";
}

?>
<form action="isset.php" method="post">
<p>Idade:<input type="text" name="Idade" value="" /></p>
<p>Valor:<input type="text" name="Valor" value="" /></p>
<p><input type="submit" value="Enviar!" /></p>
</form>
</html>

Re: Null value

Posted: Wed Jan 13, 2010 8:59 am
by mariolopes
Solved
if(isset($_POST['Idade']) || $_POST['Idade']&&""){

Re: Null value

Posted: Wed Jan 13, 2010 10:44 am
by AbraCadaver
You're not going to get a null value from a form, maybe an empty value:

Code: Select all

if(isset($_POST['Idade']) && !empty($_POST['Idade'])){
    //
}