"Paul Kaiser" <[EMAIL PROTECTED]> wrote in message
news:58851.208.216.64.17.1035495310.squirrel@;illinimedia.com...
> I have around 50 checkboxes on an HTML form. Their "value" is "1". So,
> when a user check the box, then no problem -- the value returned by the
> form is "1" and I can enter that into my SQL database.
>
> HOWEVER...
>
> If the user does not check the box, I'm in trouble, because the "value"
> does not default to "0", but rather <nil> I'm guessing...


You can take advantage of the way PHP parses passed values...

If you have two (or more) form inputs with the same name, the last value
over-writes the previous one(s).  ie if your script is called like
   myscript.php?n=0&n=1
then you get
  $_GET["n"] == 1

Sure, you say, but how can I make use of that?

Well, if the last value weren't sent, you would still have the previous
value, ie $_GET["n"] == 0

Try this:

    <input type=hidden name=n value=0>        // this value is *always* sent
    <input type=checkbox name=n value=1>    // this value is only sent if
checked!

NOTE:  the order is important!  The conditional input must come *after*
the default!



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

Reply via email to