update date_of_birth project and rename file

This commit is contained in:
Tutur33
2023-12-01 20:11:51 +01:00
parent ab09ad1d52
commit aab2d01987
6 changed files with 111 additions and 89 deletions
+79
View File
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Which Day of the Week Were You Born On?</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Which day of the week were you born on?</h1>
<form method="post">
<div>
<label for="firstName">Your first name:</label>
<input type="text" name="firstName" required>
</div>
<h2>Your date of birth:</h2>
<div class="dob">
<label for="day">Day of the month:</label>
<input type="number" name="day" required>
<label for="month">Month:</label>
<input type="number" name="month" required>
<label for="year">Year:</label>
<input type="number" name="year" required>
</div>
<button type="submit" name="submit">Validate</button>
</form>
<div>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$firstName = $_POST['firstName'];
if ($month < 3) {
$dayOfWeek = ( (int)((23 * $month) / 9) + $day + 4 + $year + ((int)($year - 1) / 4) - (int)(($year - 1) / 100) + (int)(($year - 1) / 400) ) % 7;
} else {
$dayOfWeek = ( (int)((23 * $month) / 9) + $day + 2 + $year + (int)($year / 4) - (int)($year / 100) + (int)($year / 400) ) % 7;
}
switch ($dayOfWeek) {
case 0:
$dayOfWeek = "Sunday";
break;
case 1:
$dayOfWeek = "Monday";
break;
case 2:
$dayOfWeek = "Tuesday";
break;
case 3:
$dayOfWeek = "Wednesday";
break;
case 4:
$dayOfWeek = "Thursday";
break;
case 5:
$dayOfWeek = "Friday";
break;
case 6:
$dayOfWeek = "Saturday";
break;
default:
$dayOfWeek = "Invalid day";
}
echo "$firstName, you were born on a $dayOfWeek.";
}
?>
</div>
</body>
</html>
@@ -1,12 +0,0 @@
body {
background-color: floralwhite;
}
h1,
h2 {
color: blue;
}
.ne {
display: flex;
}
@@ -1,31 +0,0 @@
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculatrice</title>
<link rel="stylesheet" href="ne_e_quel_jour.css">
</head>
<body>
<h1>Quel jour de la semaine êtes-vous (e) ?</h1>
<form method="post" action="ne_e_quel_jour2.php">
<div>
<h2>Votre prénom : </h2>
<input type="text" name="prenom" require>
</div>
<h3>Votre date de naissance SVP ?:</h3>
<div class="ne">
<h2>Jour du mois : </h2>
<input type="text" name="jours" require>
<h2>mois : </h2>
<input type="text" name="mois" require>
<h2>année : </h2>
<input type="text" name="annees" require>
</div>
<input type="submit">
</form>
</body>
</html>
@@ -1,46 +0,0 @@
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculatrice</title>
<link rel="stylesheet" href="ne_e_quel_jour.css">
</head>
<body>
<h1>Quel jour de la semaine êtes-vous (e) ?</h1>
<h3>
<?php
$nbr = $_POST['jours'];
$mois = $_POST['mois'];
$annees = $_POST['annees'];
if ($mois<3) {
$jour = ( (int)((23*$mois)/9)+$nbr+4+$annees+((int)($annees-1)/4)-(int)(($annees-1)/100)+(int)(($annees-1)/400) )%7;
} else {
$jour = ( (int)((23*$mois)/9)+$nbr+2+$annees+(int)($annees/4)-(int)($annees/100)+(int)($annees/400) )%7;
}
$nom = $_POST['prenom'];
if ($jour == 0) {
$jour = "dimanche";
} elseif($jour == 1) {
$jour = "lundi";
} elseif($jour == 2) {
$jour = "mardi";
} elseif($jour == 3) {
$jour = "mercredi";
} elseif($jour == 4) {
$jour = "jeudi";
} elseif($jour == 5) {
$jour = "vendredi";
} elseif($jour == 6) {
$jour = "samedi";
}
print("$nom, vous êtes né(e) un $jour.");
?>
</h3>
</body>
</html>
+32
View File
@@ -0,0 +1,32 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
text-align: center;
}
h1 {
margin-top: 20px;
}
form {
margin-top: 20px;
}
input[type="text"],
input[type="number"],
button {
margin: 5px;
padding: 5px;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
cursor: pointer;
}
div {
margin-top: 20px;
font-weight: bold;
}