Well i ahve 12 check boxes
I want it so when user clicks one it goes to the database
but when user clicks no check boxes i want an error to appear
i started this code can anyone please provide me with an example
i ahve been trying to fiqure this out forever
Code:
$checkboxes = array("C49", "C49");
foreach ($checkboxes as $box) {
if (isset($_POST[$box])) {
$found = false;
break;
}
echo 'You have not entered all the required details.<br />'
.'Please go back and try again.';
exit;
}
Check Boxes PHP
Moderator: General Moderators
try javascript
It would probalby be easier to check if they have selected a box using javascript.
If you want to go to the database everytime they check a box you will have to put a onClick eventhandler on each check box to submit the form.
phpScott
If you want to go to the database everytime they check a box you will have to put a onClick eventhandler on each check box to submit the form.
phpScott
for validation, u should just use a simple javascript for onsubmit that shows a promt box when no box was checked. However, if u want to use php, than just use this: This method can become messy once reaching above 3 boxes, but you can always try looping or somthing else. Hope this helps.
Code: Select all
if( ($_POSTї'checkbox1_name']=="") && ($_POSTї'checkbox2_name']="") ) //so on
{echo 'You have not entered all the required details.<br />'
.'Please go back and try again.'; }- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK