|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2002-07-09 15:43 UTC] jazar at zacks dot com
 I use simple POST action. Some time (the same post) PHP variable gets the value, some time it doesn't. I am using the same post action from the same page. Looks like some PHP bug, or what? The same thing with diffrent kinds of browsers... I have a big list of users with different OS and browsers PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 02:00:02 2025 UTC | 
I did encounter a similar coding error: queried the $_POST array multiple times, came up empty subsequent times. CODE FIX: reset($_POST) HTTP SERVER/PHP TEST SCRIPT: <html> <body> <h1>posttest.php</h1> <form name="bar" method="post" action="posttest.php"> <p> <input name="foo_a" type="checkbox"> Foo A<br> <input name="foo_b" type="checkbox"> Foo B<br> <input name="foo_c" type="checkbox"> Foo C<br> <input name="foo_d" type="checkbox"> Foo D<br> <input name="bar[]" type="text" value="bar i"> Bar 1 <br> <input name="bar[]" type="text" value="bar ii"> Bar 2 <br> <input name="bar[]" type="text" value="bar iii"> Bar 3 <br> <input name="bar[]" type="text" value="bar iv"> Bar 4 <br> <input type="submit" value=" Submit Foos "> </p> </form> <form name="bar" method="post" action="posttest.php"> <p> <?php function get_foos() { $i_counter=0; if (isset($_POST)&&(0<count($_POST))) { $sz_ret = "<br> method = post"; while (list ($cgi_foo, $cgi_on) = each ($_POST)) { if (is_array($cgi_on)) { while (list ($cgi_bar, $cgi_val) = each ($cgi_on)) { $sz_ret .= "\n".'<br>'.$cgi_foo.'--'.$cgi_bar.'<input type="text" name="'.$cgi_foo.'['.$cgi_bar.']" value="'.$cgi_val.'">'; } } elseif (('on'==$cgi_on)&&('foo_'==substr($cgi_foo,0,4))) { $sz_ret .= "\n".'<br>'.$cgi_foo.'<input type="text" name="'.$cgi_foo.'" value="'.$cgi_on.'">'; } else { $sz_ret .= "\n<br>got: '$cgi_foo', '$cgi_on'"; } $i_counter++; } if (1>$i_counter) { echo "\n<pre>\n"; print_r ($_POST); echo "\n</pre>\n"; } } elseif (isset($_GET)&&(0<count($_GET))) { $sz_ret = "<br> method = get"; while (list ($cgi_foo, $cgi_on) = each ($_GET)) { if (is_array($cgi_on)) { while (list ($cgi_bar, $cgi_val) = each ($cgi_on)) { $sz_ret .= "\n".'<br>'.$cgi_foo.'--'.$cgi_bar.'<input type="text" name="'.$cgi_foo.'['.$cgi_bar.']" value="'.$cgi_val.'">'; } } elseif (('on'==$cgi_on)&&('foo_'==substr($cgi_foo,0,4))) { $sz_ret .= "\n".'<br>'.$cgi_foo.'<input type="text" name="'.$cgi_foo.'" value="'.$cgi_on.'">'; } else { $sz_ret .= "\n<br>got: '$cgi_foo', '$cgi_on'"; } $i_counter++; } if (1>$i_counter) { echo "\n<pre>\n"; print_r ($_POST); echo "\n</pre>\n"; } } else { $sz_ret .= "<br> no data extracted"; } $sz_ret .= "<br>i_counter = $i_counter"; return $sz_ret; } print get_foos(); ?> <br><input type="submit" value=" Submit Bazs "> </p> </form> </body></html>