This may be asking a lot, but I am looking for a way to detect the attributes in some of my form input fields.
For example:
<input type="text" name="fieldone" id="fieldone" value="[email protected]" />
I can simply use a php foreach loop to get the key => value information.
<?php
$querystring = "";
if ($_POST){ $kv = array();
foreach ($_POST as $key => $value){ $querystring .= "$key=$value<br>"; }
}
?>
And this helps with mediocre debugging reasons.
However, this only detects the name and value of the form field. How do I detect the "id" attribute, or any custom attributes I may add.
Is there a way to detect/display the attributes of POST variables? Or does php stop at the name/value?
Only Name and value are senet to the server. ID and other attributes are not sent at all (why would they).
BTW: You'll want to use print_r($_POST); or var_dump($_POST); instead of your loop.
Nothing except the name and value are sent over HTTP.
You'll need to use some JavaScript pre-processing for that.
For example, on form submit, you could use JavaScript to store all the attributes with the name, but this will be messy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With