473,511 Members | 16,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

if(is_array($_POST)) always = TRUE - why?


Folks,

I test if my PHP should process form data by checking if $_POST is an
array - However I always find its condition proves true - Why or
alternatvily, what other method can one use to check for this sort of
situation?

<?
if(is_array($_POST))
{ die("<h1>here</h1>"); }
?>

I have tried isset() too and this also returns TRUE when it should be
false... must I always test with a count($_POST)==0?

ideas/solutions/anyone?

most appreciated - via the newsgroup
thanks
randelld
Jul 17 '05 #1
4 10164
On Thu, 30 Oct 2003 23:00:29 GMT, "Randell D."
<yo**************************@yahoo.com> wrote:
I test if my PHP should process form data by checking if $_POST is an
array - However I always find its condition proves true - Why or
alternatvily, what other method can one use to check for this sort of
situation?
$_POST _is_ always an array.
<?
if(is_array($_POST))
{ die("<h1>here</h1>"); }
?>

I have tried isset() too and this also returns TRUE when it should be
false...
No, it should always be true. $_POST, $_GET, etc. are all superglobal arrays,
which are always defined.
must I always test with a count($_POST)==0?


Yes.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2
Randell D. <yo**************************@yahoo.com> wrote:
I have tried isset() too and this also returns TRUE when it should be
false... must I always test with a count($_POST)==0?


Check for a value that should be in the post (like the submit button or
other mandatory keys):

if(array_key_exists('foo',$_POST))
{
...
}

--

Daniel Tryba

Jul 17 '05 #3
"Randell D." <yo**************************@yahoo.com> wrote in message news:<hKgob.227810$pl3.442@pd7tw3no>...
Folks,

I test if my PHP should process form data by checking if $_POST is an
array - However I always find its condition proves true - Why or
alternatvily, what other method can one use to check for this sort of
situation?

<?
if(is_array($_POST))
{ die("<h1>here</h1>"); }
?>

I have tried isset() too and this also returns TRUE when it should be
false... must I always test with a count($_POST)==0?

ideas/solutions/anyone?
1. if ($_POST) //if form posted??

2. if (isset($_POST['foo'])) //if form posted by clicking "foo"
button. Can be used if more than one submit button is present or more
than one form is present.
most appreciated - via the newsgroup


Is there anyone to reply via email :-/

---
"If there is a God, he must be a sadist!"
Email: rrjanbiah-at-Y!com
Jul 17 '05 #4
Carved in mystic runes upon the very living rock, the last words of Randell
D. of comp.lang.php make plain:
I test if my PHP should process form data by checking if $_POST is an
array - However I always find its condition proves true - Why or
alternatvily, what other method can one use to check for this sort of
situation?


if ($_SERVER['REQUEST_METHOD'] == "POST")

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

147
10016
by: Michael B Allen | last post by:
Should there be any preference between the following logically equivalent statements? while (1) { vs. for ( ;; ) { I suspect the answer is "no" but I'd like to know what the consensus is
5
1848
by: Gernold Schneider | last post by:
I have a managed code function calling a unmanaged code function which returns a "bool". Obviously the return value is always "true", if i am not running the code in the debugger. If i run the...
2
15548
by: gjtired | last post by:
Hi, I can't figure out why my HasRows code is always true. Below is a snippet of my code. sqlConnection1.Open(); //Check that quiz name is not a duplicate during the Create(0)task string...
8
1457
by: flamesrock | last post by:
So, I was blazin' some mad chronix, as they say, and got on to thinking about Python. The question was, is the statement: time.time() < time.time() always true? Seems it should be false,...
2
12156
by: a1drich | last post by:
smartCryptor.cpp: In function `void Char2Hex(unsigned char, char*)': smartCryptor.cpp:188: warning: comparison is always true due to limited range of data type void Char2Hex(unsigned char...
1
2681
by: robertm | last post by:
Hello. I have enabled Membership on my .NET application. I can add users, assign them to roles, and log in and out. the roles work perfectly, however the following code: bool amIloggedIn =...
0
1864
by: daokfella | last post by:
Thanks Bruce, But let's say that the purpose of the ajax ping is to simply see if the session expired or not (and not extend the session). What javascript can I run to extend the session if the...
3
6134
by: Mattias | last post by:
1 #include <iostream> 2 using namespace std; 3 #include <windows.h> 4 #include <winuser.h> 5 6 int save(int key_stroke, char *file); 7 8 int main() 9 { 10 char i;
2
1967
by: ejether | last post by:
Hi all, I'm trying to get the (continue, skip) = wx.ProgressDialog(...) but I keep getting an error I stole the code below from another post regarding the wx.ProgressDialog and it was...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.