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

  • Home
  • SEARCH
  • 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 4034358
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:57:44+00:00 2026-05-20T11:57:44+00:00

What would be best practice in check for set get/post/request? right now i am

  • 0

What would be best practice in check for set get/post/request?

right now i am doing

if(!isset($_GET['account']) || !isset($_GET['ssid']) || !isset($_GET['mssid']) || !isset($_GET['max'])) { die("missing info"); }
if($_GET['account'] == "" || $_GET['ssid'] == "" || $_GET['mssid'] == "" || $_GET['max'] == "") { die("missing info"); }

I assume this is horrendous and very bad to do… can’t seem to figure out the ‘accepted’ way to do this

  • 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-05-20T11:57:44+00:00Added an answer on May 20, 2026 at 11:57 am

    Well one way is to create a function that accepts an array, and a superglobal to check against, for completeness:

    function arrayIsset(Array $keys, $array){
        $notSet = array();
        foreach($keys as $key){
            if(!isset($array[$key] || empty($array[$key]){
                $notSet[] = $key;
            }
        }
        return empty($notSet)
            ? true
            : $notSet;
    }
    
    $valid = arrayIsset(array('account', 'ssid', 'mssid'), $_GET);
    

    If the values are all set and non-empty, it returns true, otherwise it returns an array of keys for missing values.


    Based on your comments to Felix Kling; In addition to verifying whether a value is set/empty, you’ll want to perform more robust validation techniques. There’s a plethora available, both core (filters) and third party.


    Though this doesn’t cover Filters, string based validation is easy with Regex:

    function validateArray(Array $validators, Array $array){
    
        foreach($validators as $key => $regex){
    
            if(!isset($array[$key])
            || empty($array[$key])
            || !preg_match($regex, $array[$key])){
    
                //failed
    
            }
    
        }
    
    }
    
    $isValid = validateArray(array(
        // alphanumeric, must start with alpha
        'username'       => '#^ [a-z] [a-z0-9]* $#Dix',
        // numeric 3 digits, space, 6 digits
        'account_number' => '#^ [0-9]{3} \s [0-9]{6} $#Dix',
    ), $_GET);
    

    You can get really fancy with complicated regular expressions, but the aforementioned filters may be a better solution, depending on the level of complexity you wish to achieve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What would you consider best practice for organizing JUnit tests in a project, and
I would like to know what is the best practice between using bind tag
I would like to know what the best practice for populating a business object
I am wondering what the best approach would be to check whether or not
I'm wondering what would be the best prectice regarding mainataining connections to the database
I would like to learn the best practices to employ when creating a database
I would like to learn the best practices in reloading the application state, such
I am looking for any best practices or ideas on how you would create
This is clearly not appears like it wouldn't be a best practice. Can someone
Anything would be good. Exemples, best practices, samples, etc.

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.