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 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 be best practice to localize your ASP.NET MVC application? I would like
What would be best practice for allowing the user to store data for my
Hey all, what would be best practice for clipping the bottom borders of a
What would be the best practice for sharing localization object (in this case ResourceBundle,
Would it be considered best practice to use a single template that changes it's
What's the best practice of making a variable that would be accessible by almost
Which is the best practice in this situation? I would like an un-initialized array
I would like to get feedback on best practices in regards to querying/storing a
What would be best practice to handle removal of db row that has FK
I was wondering if people would share their best practices / strategies on handling

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.