Re: checkboxes

From: Date: Sat, 22 Jun 2002 18:01:32 +0000
Subject: Re: checkboxes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-103408@lists.php.net to get a copy of this message
M.E. Suliman wrote:
Hi I know this might be a bit easy for all you experts out there. I have multiple checkboxes and text areas in a form. In the confirmation email sent to the user I manage to get the text areas to display in the email. How would I get the results of the checkboxes to to display as well? Thanks in advance Mohamed
checkboxes are like any other input, yo ugive them a name and optionally a value, and if they are selected when the form is sent then the variable is set (usually to "on") or given the value that you assign it. For example: <input type="checkbox" name="foo" value="bar"> would yield $_REQUEST['foo']=="bar" in the script. Checkboxes can also use arrays, which usually prove to be more useful. i.e. <input type="checkbox" name="foo[apple]"> and <input type="checkbox" name="foo[banana]"> Anyways, to display it in HTML it's <?=$_REQUEST['foo']?> or echo $_REQUEST['foo']; depending on how you do things. You can also use the $_POST or $_GET vars and accomplish the same thing depending on the mehtod you use or if register globals are on then it's just $foo;

« previous php.general (#103408) next »