php validation

David
January 29, 2008, 9:47 am
php validation
How to validate checkbox and radio button using php
Alin Cojocaru
February 4, 2008, 6:35 pm
Re:
For a "POST" form, you can validate the checkbox like this:
if(isset($_POST['checkbox_name'])) {
echo 'The checkbox was selected'; //Here you do whatever you want to do next.
} else {
echo 'The checkbox wasn't selected';
}

Regarding the radio button, if you have an option like "yes" or "no", here is an example:
<input type="radio" name="option" value="yes"> <input type="radio" name="option" value="no">
//processing page
if($_POST['option'] == 'yes') {
echo '"Yes" option was selected.';
} elseif($_POST['option'] == 'no') {
echo '"No" option was selected.';
} else {
echo 'None of the options were selected.';
}
Good Luck
David
February 6, 2008, 7:55 am
Re:
Thank you very much for these important information very nice from you!!!
Am actually working on a project for a computerized system using Web technology!! I will try it Thanks a lot!!!
Jim
August 24, 2008, 11:51 pm
Re:
I also found it very helpful. Cheers.
Reply
Title:
Your name:
Your email: (email address will not be posted on the web site)
Reply:
Verification