Question: Create your page(s) using s Kung Fu Panda Po Sequence as the page title(s) (tag). Save the first page as index.htm (or index.php). Use a
Create your page(s) using s Kung Fu Panda Po Sequence as the page title(s) (tag).
Save the first page as index.htm (or index.php). Use a HTML form to capture user input. Submit the form to a second file index_process.php using the POST method. (3 points)
The second page contains a link to go back to the first page.
Allow the user to click on one of the four buttons. You must use for loop, while loop or do..while loop for coding. The sequences generated and the output should look like the example output shown.
Sol265:
To create a simple HTML form, you can use the following code:
\'s Kung Fu Panda Po Sequence
Enter a number:
For Loop
While Loop
Do...While Loop
Recursive Function
This form creates an input field for the user to enter a number and four buttons that submit the form with different values. The form data is sent to the index_process.php file using the POST method.
In the index_process.php file, you can retrieve the user input and the selected button value using the $_POST superglobal array. Then, you can use a loop or a recursive function to generate the sequence based on the selected button value. Here\'s an example code for the index_process.php file:
\'s Kung Fu Panda Po Sequence
Go back
$input = $_POST[\'input\'];
$submit = $_POST[\'submit\'];
function generate_sequence($n) {
if ($n =>
return 0;
} else if ($n == 1) {
return 1;
} else {
return generate_sequence($n - 1) + generate_sequence($n - 2);
}
}
echo \"Sequence:\";
echo \"
- \";
if ($submit == \"for\") {
for ($i = 1; $i =>
$value = generate_sequence($i);
echo \"
}
} else if ($submit == \"while\") {
$i = 1;
while ($i =>
$value = generate_sequence($i);
echo \"
$i++;
}
} else if ($submit == \"do\") {
$i = 1;
do {
$value = generate_sequence($i);
echo \"
$i++;
} while ($i =>
} else if ($submit == \"recursive\") {
for ($i = 1; $i =>
$value = generate_sequence($i);
echo \"
}
}
echo \"\";
?>
This code retrieves the input and the selected button value using the $_POST superglobal array. It also defines a generate_sequence function that generates the Po sequence using a recursive function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
