You should use array type naming loc_chks[], this also lets you use specific keys for each item, for example: loc_chks[sales]
and with PHP you have it in $_POST["loc_chks"]["sales"]
HTML (myform.html):
<label for='sales'>Sales</label>
<input type='checkbox' name='loc_chks[]' id='sales' value='Sales' /><br/>
<label for='insideSales'>Inside Sales</label>
<input type='checkbox' name='loc_chks[]' id='insideSales' value='Inside Sales' /><br/>
<label for='engineering'>Engineering</label>
<input type='checkbox' name='loc_chks[]' id='engineering' value='Engineering' /><br/>
<label for='fieldService'>Field Service</label>
<input type='checkbox' name='loc_chks[]' id='fieldService' value='Field Service' /><br/>
<label for='production'>Production</label>
<input type='checkbox' name='loc_chks[]' id='production' value='Production' /><br/>
<label for='warehouse'>Warehouse</label>
<input type='checkbox' name='loc_chks[]' id='warehouse' value='Warehouse' /><br/>
In PHP you can use implode
funciton, which lets you concatenate array items with the glue string (as first parameter)
PHP (result.php):
<?php
session_start();
if(!empty($_POST["loc_chks"]) and is_array($_POST["loc_chks"])) {
$loc = implode(' | ',$_POST["loc_chks"]);
}
?>