salve a tutti. ho un problema...
ho uno script che gestisce la mailing list, ma invia mail solo al primo indirizzo presente nel db.
avevo pensato fosse un problema nel ciclo while, ma sembra corretto.
il codice:
Codice PHP:
$link = mysql_connect('localhost', 'user', 'pwd')
or die('Connessione al db fallita.');
mysql_select_db('my_db')
or die('Selezione del database fallita.');
if (isset($_POST['subject']) && isset($_POST['text'])) {
if (trim($_POST['subject'])!='' && trim($_POST['text'])!='') {
$sql = "SELECT email_address FROM address_book";
$res = mysql_query($sql);
$subject = stripslashes($_POST['subject']);
$testo = $_POST['text'];
$testo .= "
Grazie
Il webmaster
";
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: xxx <webmaster@xxx.com>";
while (list($to) = mysql_fetch_row($res)) {
mail($to, $subject, $testo, $header);
}
} else {
// Uno o più campi sono vuoti
}
} else {
/*
Il contenuto della form non è arrivato, questo può succedere
se si accede a questa pagina direttamente senza fare il
submit da form_send_news.php
*/
}
qualche suggerimento?
grazie