Im trying to when I click in my sendForm button, I want to send an email for all of my active users.
I have this code below, and I have a While loop to send an email for every emails that I have in my condition (status = active) .
But the email is only sending for my first email in the table and not for every mail that I have.
Somebody there see why this is happening?
if(isset($_POST['sendForm']))
{
$verifyUser= $pdo->prepare("SELECT * FROM users WHERE status = ?");
$verifyUser->bindValue(1, 'active');
$verifyUser->execute();
$verifyUserRows= $verifyUser->rowCount();
if($verifyUserRows<= '0')
{
echo 'there are no active warnings';
}
else
{
while ($verifyUserResult= $verifyUser->fetch(PDO::FETCH_ASSOC))
{
$date = date('d/m/Y H:i');
$msg = "
Hi, this is my message!
Send at $data
";
sendMail('My subject',$msg,MAILUSER,$verifyUserResult['email']);
echo 'Email sent with sucess';
return;
}
}