samedi 28 mars 2015

PHP How to get an input values type through $_POST

Hi I am sending a form through post to a php file that I have made. I have been able to use $_POST["name"] to get the vales of input fields of type text/password,/etc but now I would like to also get their 'type'. So in my variable $car = $_POST["car"]; will store the value, I would like $carInputType to store the inputs type. So if in the form the person chose Mazda in a checkbox, I would like the $carInputType to hold 'checkbox' the type.


I hope I explained this well I think this could be useful for many people to learn. I have been looking around but I have not found ANYTHING to answer this. I have tried:



$radio = $_POST["fname[type]"];
$radio = $_POST["fname[type=]"];


A bit of my form is as follows:



<form id="ajax-form" onsubmit="return false;">
<div><label for="uname">Username <em>*</em></label> <input id="uname" type="text" name="uname" value="" /><p class='note' id = "userNameID"></p> </div>
</form>


Any help would be greatly appreciated. Thank you for reviewing my post.


Aucun commentaire:

Enregistrer un commentaire