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 72 73 74 75 76 77
|
<?php
//--------------------------------------------------
//CONNECTION SQL
//--------------------------------------------------
$con=mysqli_connect ("localhost","login","pass","test");
//--------------------------------------------------
//VERIFICATION CONNECTION
//--------------------------------------------------
if (mysqli_connect_errno())
{
echo "Erreur de connection Mysql : " . mysqli_connect_error ();
}
//---------------------------------------------------
//PREPARATION REQUETE
//---------------------------------------------------
$result = mysqli_query($con,"SELECT id, num_serie FROM ouapi_hardware WHERE DATE( NOW( ) ) = pfield_findegarantie");
//---------------------------------------------------
//MAIL
//---------------------------------------------------
$sujet = 'Sujet de l\'email';
$message = 'Bonjour,<br />
<strong>Voici le matériel en fin de garantie</strong><br />
merci :)
<table border ="1">
<tr>
<th>Nom du materiel </th>
<th>Numero de serie</th>
</tr>
// PHP pas pris en compte
<?php
while ($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row["id"] . "</td>";
echo "<td>" . $row["num_serie"] . "</td>";
echo "</tr>";
}
?>
// Fin PHP pas pris en compte
</table>
';
$destinataire = 'destinataire@gmail.com';
$headers = "From: \"expediteur moi\"<moi@domaine.com>\n";
$headers .= "Reply-To: <a href="mailto:moi@domaine.com">moi@domaine.com</a>\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"";
if(mail($destinataire,$sujet,$message,$headers))
{
echo "L'email a bien été envoyé.";
}
else
{
echo "Une erreur c'est produite lors de l'envois de l'email.";
}
?> |