HTML example:
<form method="post" id="form" action="form_action.php"> <input name="email" type="text" /> </form>
User fills in the input field with: dfg@dfg.com
echo $_POST['email'];
The name and value of each input on the form are sent to the server. Is there a way to get the name property? So something like ..
echo $_POST['email'].name;
EDIT: To clarify some confusion in my question;
The idea was to dynamically check each input 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 raina77ow and everyone else!
post properties php
user1178560
source share