$epnr = $_POST["epn_r"];
    header("Location:index.php?a=2&epnr=" . $epnr);
}
if ($act != "" and $act != 3) {
    // Traitement des champs a insérer
    if (!$nom || !$salle) {
        $mess = getError(4);
    } else {
        switch ($act) {
            case 1:
                // ajout d'un poste
                $idcomputer = addMateriel($nom, $os, $comment, $usage, $fonction, $salle, $adresseIP, $adresseMAC, $nomhote);
                if (FALSE == $idcomputer) {
                    header("Location: ./index.php?a=2&mesno=0");
                } else {
                    $usage = getAllUsage();
                    foreach ($usage as $key => $value) {
                        if ($_POST["{$key}"] == "on") {
                            addMaterielUsage($idcomputer, $key);
                        }
                    }
                    header("Location: ./index.php?a=2&mesno=14");
                }
                break;
            case 2:
                // modifie un poste
                if (FALSE == modMateriel($id, $nom, $os, $comment, $usage, $fonction, $salle, $adresseIP, $adresseMAC, $nomhote)) {
                    header("Location: ./index.php?a=2&mesno=0");
                } else {
                    header("Location: ./index.php?a=2&mesno=14");
                }
          
          <div class="form-group">
            <label >Fonctions</label>
            <?php 
if ($idmat != "") {
    for ($x = 1; $x <= $nbfonction; $x++) {
        if (in_array($x, $fonctions)) {
            $check = "checked";
        } else {
            $check = '';
        }
        echo "<div class=\"checkbox\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"fonction[]\" value=" . $x . "  " . $check . ">&nbsp;&nbsp;" . $fonction[$x] . "</div>";
    }
} else {
    // creation d'un poste
    $fonction = getAllUsage();
    foreach ($fonction as $key => $value) {
        echo "<div class=\"checkbox\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"fonction[]\" value=" . $key . ">&nbsp;&nbsp;" . $value . "</div>";
    }
}
?>
          </div>
    
          <!-- IP mask -->
          <div class="form-group">
            <label>Adresse IP</label>
            <div class="input-group">
              <div class="input-group-addon">
                <i class="fa fa-laptop"></i>
              </div>
              <input type="text" name="adresseIP" class="form-control" value="<?php