作成しているWebアプリのメール「システム」を設定しようとしています。ユーザーテーブルでのあなたの役割が
3
アカウントのステータスは
「アクティブ化」
その後、新しいユーザーがサインアップするか、ログインリクエストを送信すると、すべての管理者にメールが送信されます。これまではメールをハードコーディングしただけでしたが、アプリのマーケティングに関しては、企業はメールを変更するためにコードを入力する必要はありません。だから私はそれを「動的に」やろうとしています
私のモデルはほとんどトーマスに感謝します!:
{
$sql = "SELECT * from users WHERE status = 'Activated' and role = 3";
$admin_email = $this -> db -> conn_id -> prepare($sql);
$admin_email -> execute();
$emails = array();
if ($admin_email)
{
if ($admin_email -> rowCount() > 0)
{
foreach ($admin_email -> fetchall() as $row)
{
$emails[] = $this -> encrypt -> decode($row['email']);
}
return $emails;
}
}
}
とコントローラー:
{
$this -> load -> model('login_model');
$this -> load -> library('email');
$this -> load -> library('encrypt');
$emails = $this -> login_model -> admin_email();
$first = $this -> input -> post('fname');
$last = $this -> input -> post('lname');
$email = $this -> input -> post('email');
$this -> email -> from($email);
$this -> email -> to($emails);
$this -> email -> reply_to($email);
$this -> email -> subject('' . $first . ' ' . $last . ' Account Request');
$this -> email -> message('{unwrap}Hello this is ' . $first . ' ' . $last . ', I am requesting to be added to the staff log-in.{/unwrap}');
if (!$this -> email -> send())
{
$this -> session -> set_flashdata('email', 'Email Was Not Sent!');
$this -> request_account();
} else
{
$this -> session -> set_flashdata('login', 'Request Sent!');
redirect('login_controller/index', 'location');
}
}
私の観察からこれをもっと掘り下げるためだけに:
- 返された最初の行は問題なく機能しますが、テスト目的で2つの管理者アカウントがあり、今言ったように、最初の行は電子メールのみを受け取ります。そして、最初の行(最初の管理者)を削除すると、2番目の行がそれを取得するとします。そのため、foreachが失敗しているように感じますが、エラーを修正する理由や方法すらわかりません。
誰かが私がここで間違っていることを私に示すことができれば、それは素晴らしいことです、