I want if value field txtname was empty echo It is ok but it don't work in my code(if field was empty and click on button you see output with print_r(...)), Please see my demo and my code. what do I do?
Demo: http://codepad.viper-7.com/FNWcIs
<form method="post">
<input name="txtname[]">
<button>Click Me</button>
</form>
<?php
if ($_POST) {
$txtname = $_POST['txtname'];
if (!empty($txtname)) {
echo '<pre>';
print_r($txtname); // Output this is: Array ( [0] => )
} else {
echo 'it is ok';
}
}
?>
var_dump($_POST)what do you get there?Click Me