How to save multiple checkbox form


i already search anything like my question, but i not found it.. I want to showing all default role with checkbox. I have code

            <?php function shapeSpace_get_roles() {                  global $  wp_roles;                    $  roles = $  wp_roles->roles;                   return $  roles;               }             $  all_roles = shapeSpace_get_roles();             foreach($  all_roles as $  roles){                 //echo $  roles['name'];                  ?>                 <div><input type="checkbox" name="dhadb_roles[]" value="<?php echo $  roles['name']; ?>" <?php if($  roles['name'] == $  options['dhadb_roles']){ echo 'checked';} ?>></input><?php echo $  roles['name']; ?></div>             <?php } ?> 

and want to save to wordrpess with this code

            if(isset($  _POST['dhadb_roles'])  ){                 $  data=serialize($  _POST['dhadb_roles']);                  update_post_meta($  postid, 'dhadb_roles', $  data);             } 

but not saved. How to save it and tick on the input form has already saved…