Sure! This is the PHP which is inside the div
tag with id “answer”:
<?php
if ($_GET['color'] == "red") {
echo "<span style=\"color:red;\">The query string had color set to red.</span>";
} else if ($_GET['color'] == "blue") {
echo "<span style=\"color:blue;\">The query string had color set to blue.</span>";
} else {
echo "Take a look at the URL in your browser's address bar! There's no query string.";
}
?>
But please don’t use that as exemplary code, since I threw it together pretty quickly! Usually I wouldn’t use echo
to output HTML.
Attached is the full PHP file in case you want to look at the whole thing.
test-post.php (1.3 KB)