Here's my situation,
ive been studying php for a few weeks now and ive started a newsletter project to allow a user to login as an administrator and send emails to everyone in a database.
Now i've written a script which carries that out, but the output is just too basic.
What I'd like to do now is write a template file which will be included in each email whilst allowing the user logged in as admin to customize any text.
I'm not sure if i'm on the right lines but all i think I know is that it involves "implode"
Does anyone know of any good reading material on the net which will explain this to me? I'm having trouble finding anything useful I don't have to pay for.
Apologies if i havent explained myself properly.
Thanks in advance for any help.
This is as far as ive got but either it doesnt send or it says "unexpected T VALUE at line 105" but thats the last line of my code and thats just "?>" no values there :/
<?php
include ("header.php");
?>
<script language="JavaScript" type="text/JavaScript">
function add(code)
{
var pretext = document.form.message.value;
this.code = code;
document.form.message.value = pretext + code;
}
</script>
<?php
include ("includes/configFile.php");
$act = $_REQUEST['act'];
print '<p><a href=http://www.somesite.co.uk/newsAdmin/>Go Back</a></p>';
print '<form name="form" id="form" method="post" action="?act=send">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150">Subject</td>
<td width="200"><input name="subject" type="text" size="49"></td>
</tr>
<tr>
<td width="150">Message</td>
<td width="200"><textarea name="message2" cols="50" rows="15"></textarea></td>
</tr>
<tr>
<td width="150"></td>
<td width="200">
<table width="200" border="0">
<tr>
<td> <img src="images/bold.gif" alt="Bold" border="0" onClick="add(\'<b>Your Text Here</b>\')" style="cursor: pointer;"> </td>
<td> <img src="images/italic.gif" alt="Italic" border="0" onClick="add(\'<i>Your Text Here</i>\')" style="cursor: pointer;"></td>
<td> <img src="images/underline.gif" alt="Underline" border="0" onClick="add(\'<u>Your Text Here</u>\')" style="cursor: pointer;"></td>
<td> <img src="images/link.gif" alt="Insert Link" border="0" onClick="add(\'<a href="[url]http://www.somesite.com"[/url] target="blank">Your Link</a>\')" style="cursor: pointer;"></td>
<td> <img src="images/newline.gif" alt="New Line" border="0" onClick="add(\'<br>\')" style="cursor: pointer;"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
<td><div align="right">
<input type="submit" name="Submit" value="Send">
</div></td></tr></table>
</form>
';
/*if ( $act == "send" ) {
//want to send form, so check for required fields
if (($POST[subject] =="") || ($_POST[message2] == "")) {
header("Location: sendmailtest2.php");
exit;
}
//connect to database
$conn = mysql_connect("*", "", "***")
or die(mysql_error());
mysql_select_db("****",$conn) or die(mysql_error());
//get emails from subscribers list
$sql = "select email from list";
$result = mysql_query($sql,$conn) or die(mysql_error());
//create a From: mailheader
$headers = "From: Your Mailing List <you@yourdomain.com>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
function getMailContent()
{
$message = file("templates/newsletter.tpl");
$message = implode("", $message);
return $message;
}
$message = getMailContent();
//loop through results and send mail
$i = 0;
while ($row = mysql_fetch_array($result)) {
set_time_limit(0);
$email = $row['email'];
$msg[$i] = str_replace("<!--EMAIL-->", $row['email'], $message);
mail("$email", stripslashes($_POST[subject]), $msg[$i], $headers);
print "newsletter sent to: $email<br>";
$i++;
}
// }
*/
include ("footer.php");
?> [/SIZE]
-Chinrub