Jump to content

problem with isset($_POST)


niche

Recommended Posts

While testing isset($_POST) as in:if (isset($_POST)) { echo 'here';}I keep seeing 'here' displayed when $_POST is empty.So, I ran:if (isset($_POST)) { echo var_dump($_POST);echo 'here';} ... and I see: here array(0) { } How can isset($_POST) be true when echo var_dump($_POST); = array(0) { } ?

Link to comment
Share on other sites

All isset is telling you is that the $_POST array exists. To test whether the array has content, you have to test individual elements, according to their names in the original form or POST string. Example: if your form has a text input with name="password", you need to do something like this:if (isset($_POST['password']) ) { // ...

Link to comment
Share on other sites

changed isset($_POST) to count($_POST) > 0 as in:if (count($_POST) > 0) {echo var_dump($_POST);echo 'here';} Thanks Deirdre's Dad.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...