Be careful when using count($_GET). If you submit a form with empty values, it will still create keys for the fields, and yours count()will be greater than 0 and empty($_GET)will be false.
<?php
print_r($_GET);
?>
<form action="" method="get">
<input type="text" name="name">
<textarea name="mytext"></textarea>
<input type="submit">
</form>
Make sure the fields are not really empty:
function ne($v) {
return $v != '';
}
echo count($_GET);
echo count(array_filter($_GET, 'ne'));
source
share