B - Storyteller
Create a Fantasy Story Teller website that allows the user to enter details about a fantasy adventure.
The website should:
- Ask the user to enter the hero’s name using a text box
- Allow the user to choose a weapon from a drop-down list
- Ask the user to enter an enemy using a text box
- Allow the user to choose a location using radio buttons
- Send the form data to story.php using the GET method
- Retrieve the form data in story.php
- Use the information entered by the user to create and display a personalised fantasy story
- Include a link that allows the user to return to the form and create another story
<?php
$name = $_GET["name"];
$location = $_GET["location"];
echo "<p>Once upon a time, a brave hero named " . $name . " travelled to the " . $location . ".</p>";
?>
In PHP, variables can be included directly inside double quotes or joined to text using the concatenation operator (.).
Both methods can produce the same output.
<?php
$name = $_GET["name"];
echo "<p>My name is $name</p>";
echo "<p>My name is" . $name . "</p>";
?>