Re: checkboxes, radio buttons and $_POST['<name>']
| From: | Tom Rogers | Date: | Fri, 10 Jan 2003 01:51:24 +0000 |
| Subject: | Re: checkboxes, radio buttons and $_POST['<name>'] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131023@lists.php.net to get a copy of this message | ||
Hi,
Friday, January 10, 2003, 4:25:00 AM, you wrote:
JEO> Hi
JEO> HELP!!!
JEO> I have read through the manual about using $_POST['<name>'] to retrieve
JEO> data from forms, but what happens when a form element is not filled in
JEO> or checked?
JEO> If I have a checkbox on a form called "chk1" I get an error from PHP
JEO> when I try this:
JEO> $chk1 = $_POST['chk1']; // error if user did not chech the checkbox on
JEO> the form!!!
JEO> How do ya usefully retrieve the fact that a form element has not been
JEO> filled in/checked?
JEO> Be Well,
JEO> John-Erik Omland
JEO> ====================================
JEO> "Rhythm is the basis of life,
JEO> not steady forward progress.
JEO> The forces of creation, destruction, and preservation
JEO> have a whirling, dynamic interaction."
JEO> - Kabbalah
Do it like this:
$chk1 = (isset($_POST['chk1']))? $_POST['chk1'] : 'No';
replace 'No' with whatever you want for an unchecked box
--
regards,
Tom