mirror of
https://github.com/arthur-pbty/nsi.git
synced 2026-06-24 14:18:22 +02:00
Create rappel systeme
This commit is contained in:
@@ -72,7 +72,25 @@ $monthName = $months[$month];
|
|||||||
echo("<td></td>");
|
echo("<td></td>");
|
||||||
}
|
}
|
||||||
for ($i=6-$day; $i <7 ; $i++) {
|
for ($i=6-$day; $i <7 ; $i++) {
|
||||||
echo("<td>$nbr</td>");
|
$today = (date("j") == $nbr and date("n") == $month and date("Y") == $year) ? "class='today'" : "";
|
||||||
|
echo("<td $today>$nbr");
|
||||||
|
|
||||||
|
foreach ($_COOKIE as $nom_cookie => $valeur_cookie) {
|
||||||
|
$cut = explode("-", $nom_cookie);
|
||||||
|
|
||||||
|
if (count($cut) >= 3) {
|
||||||
|
$rappelday = $cut[0];
|
||||||
|
$rappelmonth = $cut[1];
|
||||||
|
$rappelyear = $cut[2];
|
||||||
|
|
||||||
|
$rappel = ($rappelday == $nbr and $rappelmonth == $month and $rappelyear == $year) ? "<br>$valeur_cookie" : "";
|
||||||
|
} else {
|
||||||
|
$rappel = "error rappel";
|
||||||
|
}
|
||||||
|
echo($rappel);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("</td>");
|
||||||
$nbr++;
|
$nbr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,8 +102,24 @@ $monthName = $months[$month];
|
|||||||
}
|
}
|
||||||
|
|
||||||
$today = (date("j") == $nbr and date("n") == $month and date("Y") == $year) ? "class='today'" : "";
|
$today = (date("j") == $nbr and date("n") == $month and date("Y") == $year) ? "class='today'" : "";
|
||||||
|
echo("<td $today>$nbr");
|
||||||
echo("<td $today>$nbr</td>");
|
|
||||||
|
foreach ($_COOKIE as $nom_cookie => $valeur_cookie) {
|
||||||
|
$cut = explode("-", $nom_cookie);
|
||||||
|
|
||||||
|
if (count($cut) >= 3) {
|
||||||
|
$rappelday = $cut[0];
|
||||||
|
$rappelmonth = $cut[1];
|
||||||
|
$rappelyear = $cut[2];
|
||||||
|
|
||||||
|
$rappel = ($rappelday == $nbr and $rappelmonth == $month and $rappelyear == $year) ? "<br>$valeur_cookie" : "";
|
||||||
|
} else {
|
||||||
|
$rappel = "error rappel";
|
||||||
|
}
|
||||||
|
echo($rappel);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("</td>");
|
||||||
$nbr++;
|
$nbr++;
|
||||||
}
|
}
|
||||||
echo("</tr>");
|
echo("</tr>");
|
||||||
@@ -94,5 +128,6 @@ $monthName = $months[$month];
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
|
<a href="index.php">back -></a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function generateRandomString($length = 10) {
|
||||||
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
$randomString = '';
|
||||||
|
|
||||||
|
// Génère une chaîne aléatoire de la longueur spécifiée
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
$randomString .= $characters[mt_rand(0, strlen($characters) - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $randomString;
|
||||||
|
}
|
||||||
|
|
||||||
|
$day = $_POST['day'];
|
||||||
|
$month = $_POST['month'];
|
||||||
|
$year = $_POST['year'];
|
||||||
|
$rappel = $_POST['rappel'];
|
||||||
|
$id = generateRandomString();
|
||||||
|
|
||||||
|
$name = urlencode("$day-$month-$year-$id");
|
||||||
|
|
||||||
|
setcookie("$name", "$rappel", time() + 315360000, "/");
|
||||||
|
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
?>
|
||||||
@@ -63,5 +63,43 @@
|
|||||||
<p>The calendar generated will display the days of the week as well as the dates for the selected month and year.</p>
|
<p>The calendar generated will display the days of the week as well as the dates for the selected month and year.</p>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
<main>
|
||||||
|
<h2>Add a rappel :</h2>
|
||||||
|
<form method="post" action="create_rappel.php">
|
||||||
|
<label for="">Day :</label>
|
||||||
|
<select name="day">
|
||||||
|
<?php
|
||||||
|
for ($j = 1; $j <= 31; $j++) {
|
||||||
|
$selected = ($j == date("d")) ? 'selected' : '';
|
||||||
|
echo "<option value='$j' $selected>$j</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="">Month :</label>
|
||||||
|
<select name="month">
|
||||||
|
<?php
|
||||||
|
foreach ($months as $value => $label) {
|
||||||
|
$selected = ($value == date("n")) ? 'selected' : '';
|
||||||
|
echo "<option value='$value' $selected>$label</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="">Year :</label>
|
||||||
|
<select name="year">
|
||||||
|
<?php
|
||||||
|
for ($i = date("Y")-100; $i <= date("Y")+100; $i++) {
|
||||||
|
$selected = ($i == date("Y")) ? 'selected' : '';
|
||||||
|
echo "<option value='$i' $selected>$i</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="rappel">Rappel :</label>
|
||||||
|
<input type="text" name="rappel" required>
|
||||||
|
<button type="submit">Validate</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user