Page 1 of 1

mass email

Posted: Sat Nov 29, 2003 5:41 pm
by Wldrumstcs
im a newb, so be gentle. ok, what i need to do is created a page like 'admin.php' where i type something into a textarea and it sends to all the emails in a column in a mysql DB. I have a script, but it does not actually send the emails out, so i am baffled. Help me out and tell me what I have to do.

Code: Select all

<form method="post" action="<?php echo $PHP_SELF?>">
	<p><textarea rows="7" name="tidbit" cols="38"></textarea></p>
	<p>&nbsp;</p>
	<p><input type="submit" value="submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

<?
if ($submit) {

mysql_connect("localhost","----","----") or die ("Unable to connect to MySQL server."); 
$db = mysql_select_db("-----rs") or die ("Unable to select requested database.");
 
$result = mysql_query("SELECT email FROM members")
    or die("Invalid query: " . mysql_error());


while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { 
$to .= $line['email'].","; 
} 
$to = substr($to, 0, -1); 
$subject = "Your weekly TidBit"; 
$message = $tidbit; 
$headers = "From: webmaster@tidbitfacts.com"; 
mail($to, $subject, $message, $headers); 

} ?>

Posted: Sun Nov 30, 2003 2:46 pm
by Linkjames
PHP dosen't automatically read form variables anymore. You need to change

Code: Select all

$message = $tidbit;
to

Code: Select all

$message = $_POST['tidbit'];
I don't know if thats whats preventing your email being sent though.

Posted: Sun Nov 30, 2003 10:31 pm
by JAM
If that really is the case, then viewtopic.php?t=511 would be essential reading as the script would break on $submit also.