The thing can do is as follows:

When i want check such empty boxes, i call up the $HTTP_POST_VARS just like
you. BUT what i do next ist that while listing those vars i insert an if
statement like

if (!strstr($key,checkbox_name)) {echo ($error);}

So i do a stringmatch with the key and the name... this way you can check
all checkboxes if the have generic starting like check_01 check_02 so then
you just ask.... if (!strstr($key,chec)) {echo ($error);}

For strstr function see the manual if you dont know.

Another way is as follows...
And its probably the best!.

You can start putting checkbox values into an array... like this....
<input type=checkbox name="<?php echo("cb_[$i]"); ?>" value="bla">

cb_ then represents the array and THIS array gets transported within the
$HTTP_POST_VARS or rather exists as long as the page is up or reloaded.

Inside the listing of $HTTP_POST_VARS you then just do another array listing
for the cb_ array like this:

while (list($key, $val) = each($HTTP_POST_VARS)) {
            if (strstr($key,'cb_')) {
                    $v_ok=1;
                    while (list($key, $val) = each($cb_)) {
                        $v_liste.=' '.$val;
                        $v_user_liste =
eregi_replace("$val","",$user_liste);
                    }
                }
            }

The only backdrop is that you would have to initilaize those array elements
with an '' before....

Works very nicely for me though.. since most checkbox elements are groups
and get pulled out of a database. So the initializing is generic too ;)

Maybe this helps, regards Jens



on 19.06.2001 1:46 Uhr, Tom Beidler at [EMAIL PROTECTED] wrote:

> I have a form with approximately 40 input fields. When a form is posted it
> sends an email and then builds a tab delimited $txt entry for a text file on
> the server.
> 
> The problem is that if a checkbox is not checked, when it's not required, I
> don't get a blank entry in my tab file for the checkbox input. I'm imploding
> my HTTP_POST_VARS variable like so;
> 
> reset($HTTP_POST_VARS);
> while (list($var, $value) = each($HTTP_POST_VARS)) {
> if (is_array($value)){
> $txt .= implode($value, "\t");
> $txt .= "\t";
> }
> else{
> $txt .= "$value\t";
> }
> }
> $txt .= "end\n";
> $flsfile = fopen("text/fls.txt", "a");
> if ($flsfile){
> fputs($flsfile, "$txt");
> fclose($flsfile);
> }
> 
> Is there a way to send a blank value if the checkbox is not set? Should I
> use a completely different strategy? Have I said Thank you enough to Rasmus
> Lerdorf and whomever else was involved in resuscitating the list?
> 
> Thanks Rasmus Lerdorf and all others involved for getting the list back up
> and running.
> 
> 
>>> .>>.>>>.>>>>>.>>>>>>>>>.>>>>>>>>
> Tom Beidler
> Orbit Tech Services
> 805.682.8972 (phone)
> 805.682.5833 (fax)
> [EMAIL PROTECTED]
> http://www.orbittechservices.com/
>>> .>>.>>>.>>>>>.>>>>>>>>>.>>>>>>>>
> 
> 

Reply via email to