dmccabe Posted December 19, 2008 Share Posted December 19, 2008 I wont post all the code as it is rather lengthy, however this is the crux of it. I have an text input field <td>REG: <input type="text" name="REG" /></td> and I have this line of PHP code: } elseif (isset($_POST['REG'])) { So it should only evaluate that PHP if $_POST['REG'] has a value. However even if I leave the text box blank, it goes in to the routine as though it has a value. Any ideas? Link to comment https://forums.phpfreaks.com/topic/137705-solved-isset-always-evaluating-as-true/ Share on other sites More sharing options...
premiso Posted December 19, 2008 Share Posted December 19, 2008 } elseif (isset($_POST['REG']) && !empty($_POST['REG'])) { empty Should do the trick. Link to comment https://forums.phpfreaks.com/topic/137705-solved-isset-always-evaluating-as-true/#findComment-719781 Share on other sites More sharing options...
carrotcake1029 Posted December 19, 2008 Share Posted December 19, 2008 With forms the variable is always sent, empty or not. Link to comment https://forums.phpfreaks.com/topic/137705-solved-isset-always-evaluating-as-true/#findComment-719793 Share on other sites More sharing options...
dmccabe Posted December 19, 2008 Author Share Posted December 19, 2008 Ah I did kind of work this out for myself after posting, but got round it like this: } elseif (isset($_POST['REG']) && (strlen($_POST['REG']) > 1)) { However I am gonna switch to the empty thing instead as looks more efficient. Thanks guys'n'gals Link to comment https://forums.phpfreaks.com/topic/137705-solved-isset-always-evaluating-as-true/#findComment-719800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.