Here's the code
<?php
 foreach ($HTTP_POST_VARS  as $Index=>$Value) {
  echo "DEBUG ::: POST Key: $Index; POST Value: $Value<br>\n";
 }
?>
### Here's the function (this is how what I catually use).
function PrintVars () {
global $HTTP_POST_VARS;
    foreach ($HTTP_POST_VARS  as $Index=>$Value) {
      echo "DEBUG ::: POST Key: $Index; POST Value: $Value<br>\n";
    }
}

The first snippet seems to work fine by itself, but if call it as a function
(as the latter snippet) then it doesn't print the variables. I have the POST
array defined as global (in the function), could that be why it takes out
the empty textbox variables?

"Justin French" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> on 08/10/02 9:13 AM, Anup ([EMAIL PROTECTED]) wrote:
>
> > Hello, I have been dealing with different form proccessing PHP scripts.
When
> > I start a new job I usually have a script that just takes the form POST
> > values and prints them to the screen, so I know what I'm working with.
Now
> > I have a question say the form has 1 field named "FirstName". If the
field
> > is left blank, sometimes my script will print the key and NO value, or
it
> > will just print out nothing, ie NO key or value.
>
> Are you certain this is happening on text fields?  Typically text fields,
> password fields and textareas allways set a key, and no value of blank.
Ie:
>
> $_POST['FirstName'] = '';
>
> Select boxes should always have a value set.
>
> Check boxes are only set IF the box was ticked.
>
> What I'd advise is that you make a quick form and test this out -- perhaps
> it was only checkboxes that were sometimes not being set?
>
>
> > any ideas.  Could it be the server (IIS or Unix/Linux) of the form and
the
> > server (IIS or Unix/Linux)  of the script.?
> > Since I do jobs for different people and environments any combination of
> > servers are possible.
>
> I've never experienced this problem on any environment -- FreeBSD, RedHat
or
> Windows.
>
>
> > The reason, for this post is that I don't know if I should always put
code
> > to check for validilty using isset all the time or should I put it in
just
> > in case the script gets moved. I want to pinpoint this so that I can
write
> > more effective code.
>
> You should be able to use isset() or empty() on text/password/textarea
form
> elements reliably.
>
> Write a SMALL test script, test it, and if it ain't working, post the code
> :)
>
>
> Justin
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to