Q695 Posted May 7, 2013 Share Posted May 7, 2013 How are these not saying to check for the same thing, because when I run the isset it's thinking $_POST['message']! that a blank entry is something there, but !='' is saying that a blank entry isn't there? I tried the isset a few times, but every time it came out allowing a blank message the same way. Is that a bug with WAMP:Apache Version :2.2.17/PHP Version :5.3.4? Quote Link to comment Share on other sites More sharing options...
akphidelt2007 Posted May 7, 2013 Share Posted May 7, 2013 (edited) No, it's per the documentation. Isset simply checks to see if the key/variable exists regardless of the value. You can use... if(isset($_POST['message']) && !$_POST['message']) This would indicate the key/variable exists but the value is empty, blank, 0, false, etc... Edited May 7, 2013 by akphidelt2007 Quote Link to comment Share on other sites More sharing options...
Q695 Posted May 7, 2013 Author Share Posted May 7, 2013 But the way $message is setup it would by default be set to NULL, and therefore not set. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 7, 2013 Share Posted May 7, 2013 all text and textarea form fields are set any time the form is submitted, even if they are empty. only checkbox/radiobuttons will not be set when they are not selected. what makes you think your variable from a form will/should be a null? your form processing code should test if a form has been submitted, then all the code within the form processing code doesn't need to individually test if text/textarea fields are set. they will be. Quote Link to comment Share on other sites More sharing options...
Q695 Posted May 8, 2013 Author Share Posted May 8, 2013 You can send a blank chat message by accident. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 8, 2013 Share Posted May 8, 2013 a user or a hacker could send your script anything that can be imagined. Quote Link to comment 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.