Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.