Advertisement
idotherest34

Untitled

Feb 14th, 2021
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. if ( (empty($subject))  &&  (empty($text)) ) {
  2.     echo "Both of these fields are empty."; }
  3.   if ((empty($subject) ) && (!empty($text)) ) {
  4.       echo "subject was forgotten.";
  5.     }
  6.   if  ((empty($text)) && (!empty($subject)) ) {
  7.           echo "you forgot the body.";
  8.                                         }
  9. if ((!empty($subject)) && ( (!empty($text))) {
  10.           echo "send the e-mail.";
  11.           $dbc = mysqli_connect('localhost', 'student', 'student', 'elvis_store')
  12.             or die('Error connecting to MySQL server.');
  13.  
  14.           $query = "SELECT * FROM email_list";
  15.           $result = mysqli_query($dbc, $query)
  16.             or die('Error querying database.');
  17.  
  18.           while ($row = mysqli_fetch_array($result)){
  19.             $to = $row['email'];
  20.             $first_name = $row['first_name'];
  21.             $last_name = $row['last_name'];
  22.             $msg = "Dear $first_name $last_name,\n$text";
  23.             mail($to, $subject, $msg, 'From:' . $from);
  24.             echo 'Email sent to: ' . $to . '<br />';
  25.             }
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement