Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:01:24+00:00 2026-06-15T17:01:24+00:00

I was looking for a catch-all way to easily determine whether any user data

  • 0

I was looking for a catch-all way to easily determine whether any user data was posted via any HTML Form — without having to worry about the intricacies of each individual Form — in order to easily prohibit unregistered users from posting any content on the site.

Assuming the Form’s action attribute is always POST, is there any potential issues with using:

if(count($_POST) > 0)

to check if any data was posted?

In other words, is there any scenario where count($_POST) might be > 0 even if the user did not submit any info via POST, or where count($_POST) might == 0 even if the user did submit any info via POST?

(I first tried isset($_POST), but that didn’t work as it returns true even if no POST data is submitted by the user.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:01:25+00:00Added an answer on June 15, 2026 at 5:01 pm

    This would be the simplest way to determine if one or more values have been sent via POST.

    if ($_POST) {
        // it is 100% reliably implied that count($_POST) > 0
    }
    

    However, sometimes you may receive a form post that doesn’t contain any keys/values. An example would be an “accept our terms of service by clicking the checkbox” type form, where the only form field is a checkbox, or submit button. Checkbox name/value pairs are only sent if the checkbox gets checked, and submit buttons name/values aren’t always sent by browsers. Another example where $_POST could have no entries could be a file upload form. A good form handler will properly behave in these scenarios. You can use the following to detect a post request in ALL circumstances.

    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        // its a post request, although we may have 0 posted values
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to validate all the data on a form that
I'm looking for a way to directly get a list of all files within
I'm looking for a way to use custom ASP.NET validators to validate input, without
I'm looking for a solution for a subdomain catch-all url in IIS Express. Basically,
IS there a way to catch all keyboard and mouse events from all applications
I'm looking for a way of checking when all threads in threadpool have finished
First of all, to get this out of the way, I've spent hours looking
Looking for a perl one-liner what will find all words with the next pattern:
Looking for a way to get path of file (and then process it in
I'm looking at Amazon's DynamoDB as it looks like it takes away all of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.