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
| <?php
$pdo = new PDO( 'mysql:host=localhost;dbname=messageries', 'root','', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$sql=$pdo->query( "SELECT * FROM user " );
if(isset($_POST['selection']) ) {
$donnees=$pdo->prepare("select * from user where id=:id ");
foreach($_POST['selection'] as $key=>$value) {
$donnees->execute(array(':id'=>$key));
if ($resultat = $donnees->fetch()) {
echo $destinataire = $resultat['mail'] ;
//$headers = 'Mime-Version: 1.0'."\r\n";
//$headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
//$headers .= "\r\n";
//$sujet = 'mise à jour' ;
//$messagerie = 'Bonjour,'."\r\n\r\n";
//$messagerie .= 'Le mail a envoyer.' ."</br>"."\r\n\r\n";
//$messagerie .= '*******************************'."</br>"."\r\n";
//$messagerie .= '*******************************'."</br>"."\r\n";
//mail($destinataire, $sujet, $messagerie, $headers) ;
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>page test</title>
</head>
<body>
<form name="form1" method="post" action="test.php">
<table width="200" border="1" cellspacing="1" cellpadding="5">
<tr>
<td>Numéro</td>
<td>Prénom</td>
<td>nom</td>
<td>Mail</td>
<td>selection</td>
</tr>
<?php
while($reponse =$sql->fetch()) {
?>
<tr>
<td><?php echo $reponse['id']; ?></td>
<td><?php echo $reponse['prenom']; ?></td>
<td><?php echo $reponse['nom']; ?></td>
<td><?php echo $reponse['mail']; ?></td>
<td><input type="checkbox" name="selection[<?php echo $reponse['id']; ?>]" id="selection" value="oui" /></td>
</tr>
<?php
}
if ($_POST['envoi']){
echo '<input type="checkbox" name="selection['.$reponse['id'].']" id="selection" value="oui" style="visibility:hidden" ;/>';
}
?>
</table>
<br/>
<p>
<label>
<input type="submit" name="envoi" value="Envoyer" />
</label>
</p>
</form>
</body>
</html> |
Partager