<?php
$mysqli = new mysqli("coection details...");
if($mysqli->coect_errno > 0){
die('Unable to coect to database [' . $mysqli->coect_error . ']');
}
$username = $user->get('username'); //this just grabs the username for the logged-in member
$getuseremail = $mysqli->query("SELECT * from members WHERE Username LIKE '$username'"); //get the member's email address, so the message will appear to come from that email address
while ($row = $getuseremail->fetch_assoc()) {
$useremail = $row["Email"];
$count++;
}
$getmembers = $mysqli->query("SELECT * FROM members WHERE IsArchived NOT LIKE 'Y' ORDER BY MemberID DESC");
if ($getmembers->num_rows == 0) {
echo '<p>There are no members on the system at the moment.</p>';
}
?>
<h1>Send a message to other Members</h1>
<p>Using your email: <?php echo $useremail; ?></p>
<form name="sendmessage" action="send-message-to-members.html" method="post">
<?php
if( isset($_POST['checkbox']) && !empty($_POST['checkbox']) )
{
$list = $_POST['checkbox'];
$to = $list;
$subject = "Message from Member";
$body = "$_POST['messagetext'];";
$headers = "From: " .$useremail;
"X-Mailer: php";
$to = "[email protected]";
$headerFields = array('BCC: '.$list.', "From: ".$useremail."X-Mailer: php"');
if (mail($to, $subject, $body, implode("rn", $headerFields))) {
//if (mail($to, $subject, $body, $headers)) {
echo("<p>Message sent successfully</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
exit();
}
// display the results returned
while ($row = $getmembers->fetch_assoc()) {
$memberid = $row["MemberID"];
$firstname = $row["FirstName"];
$surname = $row["Surname"];
$email = $row["Email"];
?>
<input type="checkbox" name="checkbox[]" id="email1" value=<?php echo $email;?> /><a href="" onclick=""><?php echo $firstname.' '.$surname;?></a><br>
<?php
$count++ ;
}
<textarea name="messagetext" rows="10" cols="40"></textarea>
<input name="sendmessage" type="submit">
</form>
برچسب:
نویسنده: آیلین رضوانی