Jump to content

[SOLVED] A small problem


zamp0e

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.