vendredi 22 avril 2016

php: get post results from multiple forms through one submit

I have a table with a list of clients, then a "modify" button then a "delete" button, and then a "add to mailing list" checkbox, each of these elements is its own form. There is also a selector at the end to chose which mailing list to add the address to. My problem is with these checkboxes. I have one submit button at the end of the table to add all of the checked emails to a file, but it only works on the last email address. Here is the code for the checkboxes:

 echo "<td>";
    echo "<form action=\"\" method=\"post\">";
    if($email!="" && $email!=null){
    echo "<label class=\"checkbox-inline\">
          <input type=\"checkbox\" name=\"mailing[]\" value=\"".$email[0][0]."\" title=\"".$email[0][0]."\"><span><i class=\"glyphicon glyphicon-envelope\"></i></span></label>";
    }else{
    echo "<label class=\"checkbox-inline\">
          <input type=\"checkbox\" disabled><span><i class=\"glyphicon glyphicon-envelope\"></i></span></label>";
    }
    echo "</form>";
    echo "</td>";

//... more code

//selector + submit

<form action="" method="post">
    <div class="col-sm-6 pull-right">
    <label class="control-label">Ajouter ces adresses à la liste:</label>
        <select class="form-control" name="liste">
            <option value=""></option>
            <?php
                $linkpdo = openConnection();
                $req = $linkpdo->prepare('SELECT * FROM AERA.mailing');
                $req->execute();
                $lists = $req->fetchAll();
                if(count($lists)<>0){
                    for ($i = 0; $i < count($lists) ; $i++){
                        echo "<option value=\"".$lists[$i][0]."\">";
                        echo $lists[$i][1];
                        echo "</option>";
                    }
                }
            ?>
        </select>
    </br>
        <button type="submit" class="btn btn-info" id="clickAll">Ajouter</button>

How can I get all of the checkbox values? Or is there another way to go about it? Thanks




Aucun commentaire:

Enregistrer un commentaire