problemas:
1.- no sube los email en el suscriptor
2.- tampoco me devuelve los msg de "ya esta suscrito o el email esta ducplicado...",etc
3.- deseo crear una plantilla base del news donde se le cambie solo el contenido interno por medio de un formulario.
He buscado por todo el foro. pero me ha sido imposible.
index.php
Código PHP:
<?php
if($seguro_del) {
include("Conn.php");
$result = @mysql_query("SELECT email FROM `boletin` WHERE `email` LIKE ' $email '");
if(mysql_num_rows($result) != 0) {
$sql = @mysql_query("DELETE FROM `boletin` WHERE `email`=' $email '");
$msg = " El correo electrónico se ha removido, no recibir? nuestras novedades. ";
} else {
$msg = " El email que solicitaste para darlo de baja no existe en la base de datos. ";
} } elseif($seguro_ins) {
include("Conn.php");
$sql = "SELECT email FROM `boletin` WHERE `email` LIKE ' $email '";
$result = mysql_query($sql);
if(mysql_num_rows($result) != 0) { $msg = " El email que indicaste para la suscripción ya se encuentra registrado en la base de datos. "; } else {
if (!ereg("^[^@]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,}$", $email)) { $msg =" Tu correo electrónico no existe o esta mal escrito. "; } else {
$fecha = date("Y/n/d H:i:s");
$sql = "INSERT INTO `boletin` SET `email`=' $email ', `fecha`=' $fecha '";
$result = mysql_query($sql);
$msg = " La suscripción fue un éxito, recibirás las novedades de nuestro sitio. ";
} } }
?>
<html>
<head>
<title>Suscribir al boletín</title>
</head>
<body>
<div align="center">
<?php if($msg) { ?>
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td><div align="center" class="texto_gral"><?=$msg;?></div></td>
</tr>
<tr>
<td><div align="center"><a href="javascript:window.close()"><strong>cerrar ventana</strong></a></div></td>
</tr>
</table>
<? } else { ?>
<form action="index.php" method="post" name="" id="">
<table width="200" border="0" cellspacing="2" cellpadding="0">
<tr>
<td><input name="email" type="text" id="email" value="tu correo electrónico" size="25">
</td>
</tr>
<tr>
<td> <div align="right">
<input name="seguro_ins" type="submit" id="seguro_ins" value="suscríbete">
<input name="seguro_del" type="submit" id="seguro_del" value="desinscribir">
</div></td>
</tr>
</table>
</form>
<? } ?>
</div>
</body>
</html>
Código PHP:
<html>
<head>
<title>Envío de emails</title>
</head>
<body>
<?
if($seguro_env) {
include("../Conn.php");
$sql = mysql_query("SELECT * FROM `boletin`");
$n = 1;
while($row = mysql_fetch_array($sql)) {
$asunto ="Boletín NO.1";
$headers = "MIME-Version: 1.0\r \n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r \n";
$headers .= "From: \"BoletÎn de E-Reciclaxe\" <[email protected]>\r \n";
if(!$mensaje) { echo "No haz escrito el boletín!"; } else {
mail("".$row["email"]."","$asunto","$mensaje\n\n","$headers");
echo "<div>".$n++.". Enviado email a <b>".$row["email"]."</b><br></div>";
}
}
} else {
?>
<form action="enviarboletin.php" method="post" name="" id="">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><font size="4" face="tahoma, Arial, verdana"><strong>Puedes usar HTML
para el boletín.</strong></font></td>
</tr>
<tr>
<td><textarea name="mensaje" cols="50" rows="5" id="mensaje"></textarea></td>
</tr>
<tr>
<td><input name="seguro_env" type="submit" id="seguro_env" value="Enviar"></td>
</tr>
</table>
</form>
<? } ?>
</body>
</html>