I've got a script that sends out emails.
It goes through a for loop, where it finds all subscribers, gets their name and sets a POST
var with their name in it.
Next I've got a separate PHP file which contains the markup of the email and content.
It has a $_POST['fname']
var which is the users name and needs to be updated dynamically.
The problem is I'm unsure how to grab the contents of my email file (template.php
) and add it into the email processing file (bulk_send.php
) so that the $_POST['fname'] var can be dynamically updated. Here's the code.
foreach ($emailList as &$value) {
$getSubscriber = mysql_query("SELECT * FROM subscribers WHERE email = '$value' ");
while($row = mysql_fetch_assoc($getSubscriber)){
$_POST['fname'] = $row['fname'];
$_POST['lname'] = $row['lname'];
}
//WHERE IM STUCK
$bodyText = ***INCLUDE template.php .....***
//Code that will send out the email with $bodyText as the body of the email
}
The contents of our template.php
is something simple - lets just say something like:
<div><?php echo $_POST['fname')." ".$_POST['lname]; ?></div>
How could I include template.php file appropriately in the Foreach loop above so that the POST vars are updated with each iteration?