Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( (empty($subject)) && (empty($text)) ) {
- echo "Both of these fields are empty."; }
- if ((empty($subject) ) && (!empty($text)) ) {
- echo "subject was forgotten.";
- }
- if ((empty($text)) && (!empty($subject)) ) {
- echo "you forgot the body.";
- }
- if ((!empty($subject)) && ( (!empty($text))) {
- echo "send the e-mail.";
- $dbc = mysqli_connect('localhost', 'student', 'student', 'elvis_store')
- or die('Error connecting to MySQL server.');
- $query = "SELECT * FROM email_list";
- $result = mysqli_query($dbc, $query)
- or die('Error querying database.');
- while ($row = mysqli_fetch_array($result)){
- $to = $row['email'];
- $first_name = $row['first_name'];
- $last_name = $row['last_name'];
- $msg = "Dear $first_name $last_name,\n$text";
- mail($to, $subject, $msg, 'From:' . $from);
- echo 'Email sent to: ' . $to . '<br />';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement