Re[2]: [PHP] Posted form values - checkbox problem

From: Date: Mon, 18 Dec 2000 22:24:21 +0000
Subject: Re[2]: [PHP] Posted form values - checkbox problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-30947@lists.php.net to get a copy of this message
MK> cow1.php MK> <form method="post" action="cow2.php"> MK> <input type="checkbox" name="cow"> MK> <input type="submit"> MK> </form> MK> cow2.php MK> <? echo phpinfo();?> MK> If you run cow1.php, then have it submit to cow2, MK> there will be no HTTP_POST_VARS["cow"] unless MK> the "cow" is checked. I've no way of knowing MK> if 'cow' was the name of a checkbox on the form that MK> wasn't checked, or just not a checkbox at all. MK> Runing PHP4.03pl1 if that makes a difference. Okay .. you want to know how to process a form which you have no knowledge of .. yes? I am not sure why you would want to do this. If this is what you are trying to do then i don't have an answer for you. if it is just that you don't know about isset() then .. because you have written cow1.htm and cow2.php you do know what checkboxes you have. You can simply if (isset($cow)) {yada yada} Sorry i was not able to help you MK> 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> >> >> -- DSig David Tod Sigafoos mailto:dsig@teleport.com Using 'The Bat' 1.48 Beta/11 ````` ( O O ) _______oOOo__( )__oOOo_______

« previous php.general (#30947) next »