zamp0e Posted May 29, 2009 Share Posted May 29, 2009 Hello there. Is there any way to check if a $_POST does not exist ? I've been trying this: elseif(is_array($_POST['varldsdel'])=="0" || is_array($_POST['pi'])=="0" || is_array($_POST['kriget'])=="0" || is_array($_POST['vem'])=="0" || is_array($_POST['tal1'])=="0" || is_array($_POST['pythagoras'])) { echo "Du har inte svarat på alla frågor!"; } I thought this would simply give the response "You have not answered all the questions" (Du har inte svarat på alla frågor), and it does. The problem is that it always goes into that elseif, even if all questions are answered and thereby, all $_POST are defined with a value. Is there any way to simply check if the $_POST['randomname'] have been defined? Sorry if it was hard to understand, had some problems with expressing the problem in words Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/160211-solved-a-small-problem/ Share on other sites More sharing options...
KevinM1 Posted May 29, 2009 Share Posted May 29, 2009 if(!isset($_POST['some_field'])) { /* code */ } Or, if(empty($_POST['some_field'])) { /* code */ } http://www.php.net/manual/en/function.isset.php http://www.php.net/manual/en/function.empty.php Your problem is that is_array() merely checks to see if the value is an array, not whether or not it exists at all. Link to comment https://forums.phpfreaks.com/topic/160211-solved-a-small-problem/#findComment-845345 Share on other sites More sharing options...
zamp0e Posted May 29, 2009 Author Share Posted May 29, 2009 So thats where the problem was, thanks alot! Link to comment https://forums.phpfreaks.com/topic/160211-solved-a-small-problem/#findComment-845347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.