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 70 71
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml" dir="rtl">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>EMAIL LIST ...</title>
<style type="text/css">
body{background:#fff;margin:0px;padding:0px;}.form{margin:0px;padding:0px;}
#header,#footer{width:auto;background:#e9eff7;border:solid 0px #cccccc;margin:0;padding:20px;text-align:center;}
#main{margin:0;padding:20px;width:400px;background:#fff;border:solid 0px #cccccc;}
.textarea{margin-top:5px;margin-bottom:5px;width:100%;}
</style>
</head>
<body>
<div id="header">Mailling list</div>
<div id="main">
<?php
//$con = @mysql_connect("localhost","root","root")or die("connection error!");
//$db = @mysql_select_db("emails",$con)or die("DB error!");
if (isset($_POST['go']) AND $_POST['go']=='go' ){
if( empty($_POST['email']) ) {echo "Entrer au moinsun mail correcte<br/>";}
else{
$tab = explode('\r\n', $_POST['email']);
$pattren = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
$i = 0; $err=0;$ermsg="";
while($i < sizeof($tab)) {
if( !preg_match($pattren,$tab[$i]) ) {
$ermsg.="<br />lemail $tab[$i] à la ligne $i+1 est incorrecte";
$err=$err++;
}
$i++;
}
if ($err > 0){
echo '<div style="background-color=#eee;">'.$ermsg.'</div>';
goto KL;
}
else{
while($i < sizeof($tab)) {
$sql = mysql_query("insert into emails (email) values ('$tab[$i]') ") or die ("error!");
$i++;
}
if(isset($sql)) {echo"Merci <br/><meta http-equiv='Refresh' content='2; URL=".$_SERVER['PHP_SELF']."'>";}
}
}
} else {
?>
Remarques :<br/>Veuillez entrer un mail à chaque ligne<br/>
<?php
KL;
?>
<form class="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<textarea name="email" cols="40" rows="3" class="textarea">
<?php
if (is_array($tab){
while($i < sizeof($tab)) {
echo $tableau[$i].'\r\n';
}
}
?>
</textarea><br/>
<input type="submit" value="Envoi" />
<input type="hidden" name="go" value="go" />
</form>
<?php}?>
</div>
</div>
<div id="footer">2010</div>
</body>
</html> |
Partager