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 4615032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:46:56+00:00 2026-05-22T01:46:56+00:00

Are there any rules one needs to follow when naming POST variables in a

  • 0

Are there any rules one needs to follow when naming POST variables in a form or GET variables in a query string?

Thanks-

  • 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-22T01:46:56+00:00Added an answer on May 22, 2026 at 1:46 am

    TO answer the question literally, there really are no “rules” I’m aware of for naming $_POST and $_GET array keys in php. It’s an array like any other. Take a look at this working example on Codepad:

    <?php
    $_POST['♠♣♥♦'] = 'value1';
    $_POST['\'\'\'\''] = 'value2';
    $_POST['<?php echo "Hello World"; ?>'] = 'value3';
    $_POST['     '] = 'value4';
    $_POST[''] = 'value5';
    $_POST['@#$%^&*()'] = 'value6';
    
    print_r($_POST);
    

    In the case of form input names, they just have to be legal HTML “name” attributes (see below). However, in practice, a lot of unusual characters will actually work. Keep in mind that this doesn’t mean it’s a good idea. Different servers (and probably different browsers) will act differently with some characters like spaces for instance.

    As Tadeck has noted, duplicate keys will be overwritten by the last one when reading, but using brackets[] will solve this on the client side by turning the variable into an array.

    As far as naming conventions and best practices, there isn’t a lot of room. It’s suggested that you stick to A-Z a-z 0-9, dashes, and underscores. Although Ajay has suggested using database column names for form input names as a matter of convenience, many people will tell you that it is bad practice to expose information about your database to the public. I think invertedlambda probably has the closest answer here to the question, and Tadeck has the closest answer as far as best practices.

    Regarding HTML “name” attributes: http://www.w3.org/TR/html4/types.html#h-6.2

    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (“-“), underscores (“_”), colons (“:”), and periods (“.”).

    Maybe someone can enlighten me as to whether or not the above document is a rule or a recommendation, I’m by no means an expert on this subject. I seem to have no issues breaking some of these rules in practice. I also have no problem validating this example document as XHTML strict:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    </head>
    <body>
    <div><form action="" method="post">
    <div>
    <input name="♠♣♥♦" />
    <input name="''''" />
    <input name=")(&amp;#$)%#$%" />
    </div>
    </form>
    </div>
    </body>
    </html>
    

    Paste it into the validator, it will pass.


    One more best practice to add: Make your form input names or get/post keys meaningful, as with every other naming convention of course. Don’t use input1 and $_GET['param']. Use names that describe the meaning, like last_name or $_GET['sort_order'].

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

Sidebar

Related Questions

Probably an easy one: Are there any rules of thumb or pointers that could
Is there any way to get a String[] with the roles a user has
Are there are any rules for when to use Client-Side validation and when to
In designing any desktop applications, are there any general rules on how much memory
Is there any query which can return me the number of revisions made to
Is there any guideline or rule for when the view state should be enabled
Is there any way to check whether a file is locked without using a
Is there any free or commercial component written in .NET (no COM interop) that
Is there any efficiency difference in an explicit vs implicit inner join? For example:
Is there any way to capture the MouseDown even from the .NET 2.0 TextBox

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.