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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:33:02+00:00 2026-06-14T07:33:02+00:00

HTML example: <form method=post id=form action=form_action.php> <input name=email type=text /> </form> User fills input

  • 0

HTML example:

  <form method="post" id="form" action="form_action.php">
    <input name="email" type="text" />
  </form> 

User fills input field with: dfg@dfg.com

echo $_POST['email']; //output: dfg@dfg.com

The name and value of each input within the form is send to the server.
Is there a way to get the name property?
So something like..

echo $_POST['email'].name; //output: email

EDIT:
To clarify some confusion about my question;

The idea was to validate each input dynamically using a switch. I use a separate validation class to keep everything clean. This is a short example of my end result:

//Main php page
if (is_validForm()) {
    //All input is valid, do something..
}

//Separate validation class    
function is_validForm () {
    foreach ($_POST as $name => $value) {
        if (!is_validInput($name, $value)) return false;
    }
    return true;
   }

function is_validInput($name, $value) {
    if (!$this->is_input($value)) return false; 

    switch($name) {
        case email: return $this->is_email($value);  
        break;
        case password: return $this->is_password($value);
        break;
//and all other inputs
        }
    }

Thanks to raina77ow and everyone else!

  • 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-14T07:33:03+00:00Added an answer on June 14, 2026 at 7:33 am

    You can process $_POST in foreach loop to get both names and their values, like this:

    foreach ($_POST as $name => $value) {
       echo $name; // email, for example
       echo $value; // the same as echo $_POST['email'], in this case
    }
    

    But you’re not able to fetch the name of property from $_POST['email'] value – it’s a simple string, and it does not store its “origin”.

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

Sidebar

Related Questions

I have a got piece of HTML code: <form method=post action=/> <input type=hidden name=example-name
For example, I have a HTML form with several input buttons, <form action=/index.php method=post>
I have this code in my HTML form: <form action=cart.php method=post> <input type=hidden value=1
I have this HTML form saved as file-001.php : <form action=file-001.php method=post id=select-block class=general-form>
I have a submit buttom like this: <?php echo <form id='abottom' method='post'> <button name='.$row3[$ww].'
I don't know PHP. I don't want the user to go to http://www.example.com/feedback-thanks.html after
I want to take HTML form data and handle the submited data(string for example)
Trying to customize Symfony2 form to produce html code looking like the following example:
Ryan Bates' nifty_scaffolding, for example, does this edit.html.erb <%= render :partial => 'form' %>
I have a problem in PHP. I am using <input type=file> to get the

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.