Re: Posted form values - checkbox problem

From: Date: Mon, 18 Dec 2000 22:06:32 +0000
Subject: Re: Posted form values - checkbox problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-30943@lists.php.net to get a copy of this message
cow1.php <form method="post" action="cow2.php"> <input type="checkbox" name="cow"> <input type="submit"> </form> cow2.php <? echo phpinfo();?> If you run cow1.php, then have it submit to cow2, there will be no HTTP_POST_VARS["cow"] unless the "cow" is checked. I've no way of knowing if 'cow' was the name of a checkbox on the form that wasn't checked, or just not a checkbox at all. Runing PHP4.03pl1 if that makes a difference. David Tod Sigafoos wrote: > Hello Michael, > > Monday, December 18, 2000, 13:51:27 PM, you wrote: > > MK> <input type="checkbox" name="cow"> > MK> <input type="checkbox" name="pig"> > MK> <input type="checkbox" name="dog"> > > MK> If cow is 'checked', I get $cow="on", > MK> but if cow is left unchecked, I get $cow="". > > MK> If I knew the names of the variables I was > MK> getting, I could check to see if they were 'on' or '', > MK> but I don't know. I'm getting an array of disparate > MK> values, and I can't tell which checkboxes were on > MK> or off, only those that were on. > > MK> Any ideas, short of including a separate hidden value that > MK> tells me which variable names I'll be getting? > > I am sure I am missing something .. but the control 'name' is the var > name. You know you have a checkbox called cow, pig and dog so you > will have vars $cow, $pig and $dog... yes? > > wait a minute .. am i on candid camera? <g> > > -- ========================== Michael Kimsal http://www.tapinternet.com PHP Training courses http://www.tapinternet.com/php

« previous php.general (#30943) next »