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>
Null value
Moderator: General Moderators
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Null value
Solved
if(isset($_POST['Idade']) || $_POST['Idade']&&""){
if(isset($_POST['Idade']) || $_POST['Idade']&&""){
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Null value
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'])){
//
}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.