PHP and MySQL Mailout

Soldato
Joined
28 Apr 2011
Posts
15,221
Location
Barnet, London
Can anyone give me some pointers on the best way to do this.

I have a table with people in with the usual details, including an email address, their name and a unique key.

At the moment I'm setting up a form, iterating through the table displaying their name and a tick box, the id being the unique key.

Code:
while($row = mysqli_fetch_array($result)) {
                        $team=strtolower($row['team']);

                        if($row['email'] == "") {
                            $team = 'white';
                        }

                        ?>
                        <div class="col-sm-30 <?php echo $team.'Background'; ?>">
                            <input class="form-group-input" type="checkbox" value="<?php echo $row['uniqueid']; ?>" name="<?php echo $row['uniqueid']; ?>" id="<?php echo $row['uniqueid']; ?>" <?php if($team == 'white') { echo 'disabled'; } ?>>
                            <label class="form-checkbox form-label-inlin" for="<?php echo $row['uniqueid']; ?>">
                            <?php echo checkPartnerName($row['uniqueid']); ?>
                            </label>
                        </div>
                        <?php
                    }

When it then posts, how am I best to go through getting the people's details? Can I iterate through $_POST?

Does that all make sense?

I'm sure there's a better way to do this though, I just don't know how?
 
Thanks for the replies.

What exactly are you trying to do?

Is this just a visual thing of who has been sent an email or when you manually tick the box it sends them an email?

It brings a list of everyone in the database. You tick ones you want to receive the email. Press submit and they all get sent an email.

Don't use the $_POST to send the details, that could be manipulated. Post a list of the uniqueid values from the selected checkboxes then go and retrieve the email addresses from the database for each id.

Yes, that's what I'm doing above, although I'm asking if I can iterate through $_POST to do so. Is there a better way to do it? Are you saying I can/should send them all in one post and then split them back up and iterate on the next page?
 
Back
Top Bottom