cdoggg94 Posted May 29, 2014 Share Posted May 29, 2014 I have a script where you add an entry into a DB. I want to take everyone from another table in this DB and send the newly added content to them.My problem is displaying all of the contacts into the $to= location.This is what I currently have: <?php error_reporting(-1); //-------------email section----------------// $title = $_POST['title']; $story = $_POST['story']; $date = $_POST['date']; //do { //$to = $row_Fake['fake_email']; //} //while($row_Fake = mysql_fetch_assoc($Fake)); while ($row_Fake = mysql_fetch_assoc($Fake)) { $to = $row_Fake['fake_email']; } //$to = "colinrblambert@gmail.com"; $subject = "New Halnor Update!"; $message = " <html> <head> <title>New Update!</title> </head> <body> <div align='center'>"; //do{ echo $row_Fake['fake_email'].", "; } while($row_Fake = mysql_fetch_assoc($Fake)); //$row['fake_email']; "We have a new update from ".$date." to share with you !<br /><br /> <table border='0'> <tr> <td valign='top' width='200'><b>".$title."</b></td> <td>".nl2br($story)."</td> </tr> </table> </div> </body> </html> "; $x = 1; $str = "test"; do{ $str .= $x; $x++; }while($x<10); // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // More headers $headers .= 'From: <admin@website.com>'. "\r\n"; //$headers .= 'Cc: myboss@example.com' . "\r\n"; mail($to,$subject,$message,$headers); } header(sprintf("Location: %s", $insertGoTo)); } ?> Kind of lost right now. Can someone help? Quote Link to comment Share on other sites More sharing options...
adam_bray Posted May 29, 2014 Share Posted May 29, 2014 Where are you defining $Fake? From what you've posted I don't see a query being executed. I don't think you'd want to insert all the email addresses into 1 $to variable, you'll probably want to loop the process, otherwise you'll find all emails will be flagged as spam. You also need to switch from mysql_* functions to mysqli_* . Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 30, 2014 Share Posted May 30, 2014 to hide your user's email addresses from each other, you need to put them into a bcc: field. by putting them all into the to: field, the entire list will be visible to everyone who receives the email (and anyone can then hit reply-all to spam all your members.) when using a bcc: field, you would use your own from: email address as the to: address. to make a list of email addresses, you would form a comma separated list. your current code only assigns one value over an over inside the while(){} loop, which would end up being the last value after the end of the while(){} loop. Quote Link to comment Share on other sites More sharing options...
cdoggg94 Posted May 30, 2014 Author Share Posted May 30, 2014 $fake is defined like this: <?php mysql_select_db($database_HalNor, $HalNor); $query_Fake = "SELECT* FROM fake_tbl"; $Fake = mysql_query($query_Fake, $HalNor) or die(mysql_error()); $row_Fake = mysql_fetch_assoc($Fake); $totalRows_Fake = mysql_num_rows($Fake); ?> Thank you both for the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.