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? Quote 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. Quote 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. Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.