i'm working on permissions in php,my requirement is i have list of menus..based on user role i have to give access to them.so a single user have access to multiple menus..my idea is i will select check boxes and store it in single database columns.and if i check any check box the value should be 'y' in database column field.and if not check means value should be 'x' in database column field(Example:y,x,x,y) i have a table like this following.. i'm working on permissions in php,my requirement is i have list of menus..based on user role i have to give access to them.so a single user have access to multiple menus..my idea is i will select check boxes and store it in single database columns.and if i check any check box the value should be 'y' in database column field.and if not check means value should be 'x' in database column field(Example:y,x,x,y) i have a table like this following..
role id,role name,permissions,description...
my code:
<form class="form-horizontal tasi-form" method="POST" name="register-form" id="register-form">
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label">Roles Title</label>
<div class="col-sm-10">
<input type="text" class="form-control round-input" name="roletitle" id="roletitle">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label">Permission</label>
<div class="col-sm-10">
<input type="checkbox" name="sb[]" id="checkbox_php" value="EMPLOYEES"/><label for="checkbox_php">EMPLOYEES</label>
<br/>
<input type="checkbox" name="sb[]" id="checkbox_asp" value="UNIT"/><label for="checkbox_asp">UNIT</label><br/>
<input type="checkbox" name="sb[]" id="checkbox_asp" value="SERVICES"/><label for="checkbox_asp">SERVICES</label><br/>
<input type="checkbox" name="sb[]" id="checkbox_asp" value="Appointment"/><label for="checkbox_asp">Appointment</label><br/>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 col-sm-2 control-label">Roles Description</label>
<div class="col-lg-10">
<textarea name="description" id="editor1" class="form-control" cols="30" rows="10"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 col-sm-2 control-label"></label>
<div class="col-lg-10">
<input type="hidden" value="roles" name="requesttype"/>
<button type="submit" class="btn btn-success">Save</button>
</div>
</div>
</form>
php code:
<?php
include("../config.php");
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'roles'){
$insertInfo=array();
$insertInfo['ROLES_TITLE'] = $_REQUEST['roletitle'];
$insertInfo['PERMISSIONS'] = $_REQUEST['permission'];
$insertInfo['ROLES_DESCRIPTION'] = $_REQUEST['description'];
$date=date('Y-m-d H:i:s');
$insertInfo['CREATED_ON']=$date;
$insertinfo['UPDATED_BY']='';
$insertInfo['UPDATED_ON']=$date;
$res=$db->insert('ROLES', $insertInfo);
if($result)
{?>
//header("location:city");
<script>
window.location.href='rolesa';
</script>
<?php }
} ?>
implode(',',$_POST['sb']);