Forum Moderators: coopster

Message Too Old, No Replies

PHP form debugging.

A script to just list all the details that were sent...

         

salnajjar

3:40 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



For testing and debugging I currently have a very simple PHP page that when I go to it lists out all of the session variables that are currently set for me so that I can tell when things aren't quite working right.

I'm wondering if anyone has the equivalent for forms? A simple php script that when you set it as the form action simply splurts onto the page all the variables and details that were submitted.

I can't quite get my head around how to code such a thing and figured that it might be of use to others too.

I'm guessing it would be something like:

while ($var = each($_POST)) {
printf ("Posted item <b>%s</b> has the value of: <b>%s</b><br>", $var['key'], $var['value']);
}

This works for some items but appears to break if there's multiple select boxes with the same name but different values.

Thanks for any help.

Seri

salnajjar

4:18 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



Well, I've almost answered my own question and discovered something new about HTML forms and PHP.

Apparently if I'm using multiple select boxes with the same name then I need to insert [] at the end of the name string (such as name="messageselect[]" ). This is so that the posted item becomes an array of variables with I can later act upon.

I'm still tweaking a debug page but I think I've now answered the problem that I was hoping to fix with a debug page in the first place.

Seri