JDrEd Posted June 17, 2008 at 11:05 PM Report Share #191809 Posted June 17, 2008 at 11:05 PM Boas, sei pouco de php e tenho andado a tentar fazer uma mail lista, a inscrição dos utilizadores, administração destes já fiz e está tudo ok 🙂 Agora falta fazer um php para ir a base de dados buscar os vários mails dos utilizadores e enviar um mail definido por mim para estes. Tentei fazer o que vou postar abaixo, mas está a dar uma série de erros. Estrutura da base de dados CREATE TABLE noticias ( id int(5) NOT NULL auto_increment, nome char(30) NOT NULL , email char(80) , data date NOT NULL, hora time NOT NULL , ver char(3) DEFAULT 'off' , PRIMARY KEY (id), UNIQUE id (id) ); O ver fica por default off, e depois é modificado por mim (como que uma aceitação do registo), agora queria mandar um mail para todos os utilizadores registados na bd e que o ver estive-se on. Isto foi o que fiz 😄 <html> <head> <title>Formulario de E-mail</title> </head> <body> <table width="80%" align="center"> <form action="mail.php" method="post" name="formulario" id="formulario"> <tr> <td width="20%">Seu Email</td> <td><input type="text" name="meu" size="50" maxlength="255"></td> </tr> <tr> <td width="20%">Assunto</td> <td><input type="text" name="titulo" size="50" maxlength="255"></td> </tr> <tr> <td colspan=2>Sua Mensagem<br> <textarea cols="53" rows="5" name="texto"></textarea> </td> </tr> <tr> <td colspan=2 align="center"><input type="submit" value="Enviar Email"></td> </tr> </form> </table> </body> </html> <?php $conexao = mysql_connect("localhost","XXXX","XXX"); $db = mysql_select_db("ciaia_ciaia"); $sql = "SELECT * FROM newsletter WHERE e='$id'"; $resultado = mysql_query($sql) or die ("Não foi possível realizar a consulta ao banco de dados"); while ($linha=mysql_fetch_array($resultado)) { $email = $linha["email"]; $destino = $email; $rementente = $meu; $assunto = $titulo; $mensagem= $texto; $headers = "Content-Type: text/html; charset=iso-8859-1"; $headers.="From:".$rementente.""; mail("$destino", "$assunto", "$mensagem","$headers"); ?> Desculpem lá os erros :S Se me pudessem dar uma ajuda agradecia Grande Abraço Link to comment Share on other sites More sharing options...
fnds Posted June 17, 2008 at 11:07 PM Report Share #191810 Posted June 17, 2008 at 11:07 PM Mostra os erros que dá. Link to comment Share on other sites More sharing options...
JDrEd Posted June 17, 2008 at 11:13 PM Author Report Share #191813 Posted June 17, 2008 at 11:13 PM Antes de tudo obrigado pela resposta rápida. O erro que está dando é o seguinte: Parse error: syntax error, unexpected $end in /home/ciaia/public_html/admin/mail.php on line 22 Grande abraço Link to comment Share on other sites More sharing options...
anuska Posted June 17, 2008 at 11:28 PM Report Share #191818 Posted June 17, 2008 at 11:28 PM da erro numa linha que não existe! ele ta a dizer que não encontra o fim. $end, tem de ver se falta uma chaveta ou alguma coisa por fechar Link to comment Share on other sites More sharing options...
anuska Posted June 17, 2008 at 11:30 PM Report Share #191819 Posted June 17, 2008 at 11:30 PM falta fechar o while no fim da pagina 😄🙂 Link to comment Share on other sites More sharing options...
JDrEd Posted June 18, 2008 at 12:03 AM Author Report Share #191822 Posted June 18, 2008 at 12:03 AM Obrigado anuska, realmente foi uma falta de atençao parva mesmo 🙂 Agora dá outro erro 😄 Não foi possÃvel realizar a consulta ao banco de dados Help? Abraços Link to comment Share on other sites More sharing options...
JDrEd Posted June 18, 2008 at 12:12 AM Author Report Share #191824 Posted June 18, 2008 at 12:12 AM Já consegui, troquei a 5ª linha por " $sql = "SELECT * FROM newsletter ORDER BY id DESC"; " Só falta agora é mesmo apenas mandar para os que têm o ver = on. Abraço Link to comment Share on other sites More sharing options...
JDrEd Posted June 18, 2008 at 12:46 AM Author Report Share #191831 Posted June 18, 2008 at 12:46 AM prontos ta resolvido, mudei a 5ª linha novamente para: $sql = "SELECT * FROM newsletter WHERE ver = 'on' ORDER BY id DESC"; E já faz o que eu queria. Peço desculpa pelos post seguidos. Abraço Link to comment Share on other sites More sharing options...
anuska Posted June 18, 2008 at 11:38 AM Report Share #191875 Posted June 18, 2008 at 11:38 AM fixe 😄 Link to comment Share on other sites More sharing options...
anuska Posted June 19, 2008 at 06:55 PM Report Share #192243 Posted June 19, 2008 at 06:55 PM Ola! não da para fazer este exemplo com classes? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now