Php/mysql - newsletter prob supression user

Fermé
petitwebmaster - 12 déc. 2007 à 05:44
 le père - 12 déc. 2007 à 08:02
Bonjour,
J'ai une page de newsletter, tout marche sauf la desinscription,

Pourtant, il affiche bien que l'email ) été enlevé mais il est toujour dans la base

Aidez-moi svp

voici ma page php


<?
if(isset($_POST['newsletter'])){

if (!function_exists('checkdnsrr')) {
function checkdnsrr($host, $type = '') {
if(!empty($host)) {
if($type == '') $type = "MX";
@exec("nslookup -type=$type $host", $output);
while(list($k, $line) = each($output)) {
if(eregi("^$host", $line)) return true;
}
return false;
}
}
}

$email=$_POST['email'];
$etat=$_POST['etat'];

function check_mail($champ4) {
if( (preg_match('//', $champ4)) ||
(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$champ4)) ) {
$host = explode('@', $champ4);
if(checkdnsrr($host[1].'.', 'MX') ) return true;
if(checkdnsrr($host[1].'.', 'A') ) return true;
if(checkdnsrr($host[1].'.', 'CNAME') ) return true;
}
return false;
}
$ok = 0;
if ($email == ""){
echo("<div align='center'> <span class='Style1'><strong>Vous n'avez pas complété adresse mail </strong> </span></div>");
$ok = 0;
}
else {
if (check_mail($email)) {
$ok = 1;
}
else {
echo(" <div align='center'><span class='Style1'> <strong>L'adresse e-mail n'est pas valide<br></strong> </span> </div>");
$ok = 0;
}
}




if($ok==1){
$reponse = "SELECT * FROM ".T_MAIL." WHERE mail='$email'";
$s=mysql_query($reponse);
if (mysql_num_rows($s)>0)
{
$modif=mysql_query("UPDATE ".T_MAIL." SET etat='$etat' WHERE mail='$email'");
echo'<div align="center"> <span class="Style1"><strong>Modification effectuée</strong> </span> </div>';
}else{
$modif = mysql_query("INSERT INTO ".T_MAIL." VALUES('', '$email', '$etat')");
echo'<div align="center"> <span class="Style1"><strong>Inscription effectuée</strong> </span> </div>';
}
}
}
?><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.Style1 {color: #000000}
-->
</style>



<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">
<form action="" method="post" style= float: left">
<input name="email" type="text" style="border:1px solid #000; font-size: 10pt; font-family: Arial; background-color: #333; color: #FFFFFF; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1" onfocus="if(this.value=='Votre email !') this.value=''" value="Votre email !" size="23"/>
<br />
<label>
<span class="Style1">
<input type="radio" name="etat" value="1" checked="checked"/>
Inscription
<input type="radio" name="etat" value="0" />
Désinscription </span></label>
<span class="Style1">
<label> </label>
</span><br />
<input name="newsletter" type="submit" id="button" style="border:1px solid #000; font-size: 10pt; font-family: Arial; background-color: #333; color: #FFFFFF; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1" value="OK" />
</form>
</div></td>
</tr>
</table>
A voir également:

1 réponse

Bonjour,

Pour ce que je comprends de ton script, il n'enlève pas les email de ta base. Il se contente de mettre leur champ etat à 0
0