1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body
{
background-color: #FFFFCC ; etc...
}
.maroom { background-color: # FFCC99 ; color: green ; font-weight: bold ; }
</style>
</head>
<body>
Envoyer Newsletter :<br/>
<form action="envoi_news.php" method="post">
<table>
<tr><td>
<h3><span class="gras">E-mail :</span></h3>
</td><td>
<input type="text" name="titre" maxlength="50" size="50" value="<?php if (isset($_POST['email'])) echo htmlentities(trim($_POST['email'])); ?>">
</td></tr><tr><td>
<h3><span class="gras">Contenue :</span></h3>
</td><td>
<textarea name="news" cols="50" rows="10"><?php if (isset($_POST['newslett'])) echo htmlentities(trim($_POST['newslett'])); ?></textarea>
</td></tr><tr><td><td align="right">
<input type="submit" name="go" value="Envoyer Newsletter">
</td></tr></table>
</form>
<?php
if ((isset($_POST['email']) && !empty($_POST['email'])) && (isset($_POST['newslett']) && !empty($_POST['newslett'])))
{
$sql = 'INSERT INTO newsletadm (id, email, newslett) VALUES("", "'.mysql_escape_string($_POST['email']).'", "'.mysql_escape_string($_POST['newslett']).'")';
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br />'.mysql_error()); }
else
exit ();
$sql = "SELECT email FROM newsletadm WHERE email = '".$_POST['email']."' ";
$req = mysql_query($sql) or die ('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
if(mysql_num_rows($req) != 1)//si le nombre de lignes retourne par la requete != 1
exit("mail inconnu.");
else
{
$row1 = mysql_fetch_assoc($req);
$retour = mysql_query("SELECT newslett FROM newsletadm WHERE email = '".$_POST['email']."' ");
$row2 = mysql_fetch_assoc($retour);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$objet = 'Newsletter';
ini_set('SMTP','localhost');
if(!mail($row1['email'], $objet, $row2['newslett'], $headers))
echo 'probleme lors de l\'envoi du mail';
else
echo 'mail envoye';
}
?>
</body>
</html> |
Partager