Hello All,
I am trying to validate multiple checkboxes whose values are stored in an array using php. I have been trying from a really long time but nothing's working out.
Can anyone help?
Here's the code:
I would want to validate the priviliges[] array which consists of the above mentioned values. If no privilige is checked, i want to display an error message saying to check atleast one privilige.
Any help would be appreciated.
Thanks and Regards,
Dream2rule
I am trying to validate multiple checkboxes whose values are stored in an array using php. I have been trying from a really long time but nothing's working out.
Can anyone help?
Here's the code:
Code:
<form id="create_user" name="create_user" method="post" action="creating_database.php" onsubmit="return validate_create_user_form();">
<?php
$priviliges = array("SELECT","INSERT","UPDATE","DELETE","FILE","CREATE","ALTER","INDEX","DROP","CREATE TEMPORARY TABLES","CREATE VIEW","SHOW VIEW","CREATE ROUTINE","ALTER ROUTINE","EXECUTE","GRANT","SUPER","PROCESS",
"RELOAD","SHUTDOWN","SHOW DATABASES","LOCK TABLES", "REFERENCES", "REPLICATION CLIENT", "REPLICATION SLAVE");
echo "<table border=0 cellpadding=0 cellspacing=0 align=center width='100%' border='1'>";
$count = count($priviliges)."<br>";
//echo $count;
for($i = 0; $i < $count; $i++ )
{
if($i == 0)
echo "<tr>";
echo "<td align=left><input type=checkbox name=priviliges[]
value='$priviliges[$i]'>$priviliges[$i]</td>";
echo "</tr>";
}
echo "</table>";
?>
</form>
Any help would be appreciated.
Thanks and Regards,
Dream2rule
Comment