Skip to content

Commit 2f9bb2e

Browse files
019-Handling GET requests
1 parent 4abef5c commit 2f9bb2e

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

019-handling-get-requests.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$planet = isset($_GET['planet']) ? $_GET['planet'] : "Planet not found";
3+
echo "<p>The planet is: " . $planet . "</p>";
4+
5+
$color = $_GET['color'] ?? "Color not found";
6+
echo "<p>The color is: " . $color . "</p>";

019-planet.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Planet</title>
7+
</head>
8+
<body>
9+
<?php $planet = $_GET["planet"] ?? "Planet isn't defined."; ?>
10+
<p><strong>Your favorite planet is: </strong><?=$planet?></p>
11+
</body>
12+
</html>

019-planets.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Planets</title>
7+
</head>
8+
<body>
9+
<?php
10+
$planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"];
11+
?>
12+
<ul>
13+
<?php foreach ($planets as $planet) : ?>
14+
<li>
15+
<a href="019-planet.php?planet=<?= $planet ?>"><?= $planet ?></a>
16+
</li>
17+
<?php endforeach; ?>
18+
</ul>
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)