Create a single php application that will return multiple different "pages" to the user based upon their input. All your work is to be done in the file index.php. The PHP application will use a query variable called $cmd to determine which page to render. This $cmd variable is created by read the query string url. Recall anything after a "?" in the url will be passed as variables to the php program.
You would invoke these pages like:
….index.php?cmd=page1 and ...index.php?cmd=page2
Here is a code snippet that shows how you will read the variable and make decisions as to what output to render.
<?php if ($cmd=="page1"){
?
HTML for page1
<?php
}
else if ($cmd == "page2") {
?
HTML for page2
<?php
} else {
? default
<?php }?
Where $cmd is a variable that is sent to the server from the different links.
Steps:
1) There is a video showing my working solution that you can use to help understand functionality.
2) In your git working copy on ceclnx01, create a directory called php1. The file inside this directory shall be called index.php
3) Edit index.php to include Create a bootstrap PHP page with a Header, Left Menu and a Main Content Area.
4) In the Left Menu place the following three links:
a) <a href="index.php?cmd=page1"Random Numbers</a
b) <a href="index.php?cmd=page2"Images</a
c) <a href="index.php?cmd=page1"Input Form</a
d) <a href="index.php"Home</a
5) Using your browser view this page and get the HTML correct before adding any html.
6) Even though you have created a php file, there is no php code yet. At the top of the index.php file put in the following code:
<?php
/*
YOUR COMMENT BLOCK HERE (name, date, assignment..)
*/
session_start(); //create a session
//initialize number of visits session variable
$numVisits = 0; if (isset($_SESSION['num'])) { $_SESSION['num']++;
$numVisits = $_SESSION['num'];
} else {
$numVisits = 0;
$_SESSION['num'] = 0;
}
//see if the cmd get variable is passed into the program.