Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php debugging POST vars

Tags:

post

php

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?

like image 744
coffeemonitor Avatar asked Apr 12 '26 07:04

coffeemonitor


2 Answers

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.

like image 58
ThiefMaster Avatar answered Apr 14 '26 19:04

ThiefMaster


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.

like image 29
alex Avatar answered Apr 14 '26 20:04

alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!