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? Link to comment https://forums.phpfreaks.com/topic/277735-isset_postmessage-vs-_postmessage/ Share on other sites More sharing options...
akphidelt2007 Posted May 7, 2013 Share Posted May 7, 2013 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... Link to comment https://forums.phpfreaks.com/topic/277735-isset_postmessage-vs-_postmessage/#findComment-1428774 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. Link to comment https://forums.phpfreaks.com/topic/277735-isset_postmessage-vs-_postmessage/#findComment-1428780 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. Link to comment https://forums.phpfreaks.com/topic/277735-isset_postmessage-vs-_postmessage/#findComment-1428848 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. Link to comment https://forums.phpfreaks.com/topic/277735-isset_postmessage-vs-_postmessage/#findComment-1429026 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. Link to comment https://forums.phpfreaks.com/topic/277735-isset_postmessage-vs-_postmessage/#findComment-1429027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.