williamZanelli Posted November 17, 2008 Share Posted November 17, 2008 Hi guys, I have a drop down list, something like <select name="my_team"> <option></option> <option>One </option> <option >Two</option> </select> Now, if the user selects the blank option, what would the following statement return if(isset($_POST["my_team"])) I'm not entirely sure how isset is work, hence this issue. Thanks for your help in advance, Will Link to comment https://forums.phpfreaks.com/topic/133085-solved-isset-problem/ Share on other sites More sharing options...
laffin Posted November 17, 2008 Share Posted November 17, 2008 shud return "" empty string or null is my guess... Link to comment https://forums.phpfreaks.com/topic/133085-solved-isset-problem/#findComment-692103 Share on other sites More sharing options...
Mark Baker Posted November 17, 2008 Share Posted November 17, 2008 isset returns a boolean true or false. I suspect what you're after is if (!empty($_POST["my_team"])) Link to comment https://forums.phpfreaks.com/topic/133085-solved-isset-problem/#findComment-692104 Share on other sites More sharing options...
williamZanelli Posted November 17, 2008 Author Share Posted November 17, 2008 Thanks for the reply MArk, So if $_POST["my_team"] was blank, would isset($_POST["my_team"]) return true or false? Could you tell me where it would be appropriate to use, isset and where to use empty? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/133085-solved-isset-problem/#findComment-692110 Share on other sites More sharing options...
laffin Posted November 17, 2008 Share Posted November 17, 2008 isset does as it sounds, if the variable has been used, it's set. no matter wut the value is, null, false, "" u use it for checking the existance of the variable such as checkboxes, they dun return anything if not checked, and return value if it is checked if(isset($_POST['checkbox']) $ans='yes'; else $ans='no'; a simple way if ya doing all in one forms/php scripts, is checking $_POST. if(isset($_POST)) { // Process Form here } // Show form here empty can be null, "", false, 0, array() (empty array), or '0' we not checking existance of a variable, but checking if it has content if(empty($username)) { die('Empty username"); } Link to comment https://forums.phpfreaks.com/topic/133085-solved-isset-problem/#findComment-692118 Share on other sites More sharing options...
williamZanelli Posted November 17, 2008 Author Share Posted November 17, 2008 Laffin, thank you for that thorough reply. I understand now Link to comment https://forums.phpfreaks.com/topic/133085-solved-isset-problem/#findComment-692122 Share on other sites More sharing options...
amber.long83 Posted November 20, 2008 Share Posted November 20, 2008 it return null value. Link to comment https://forums.phpfreaks.com/topic/133085-solved-isset-problem/#findComment-694218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.