diff --git a/week-1/test_app/README.md b/week-1/test_app/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0bc2b71d58b736b813e3074e51eccf4985515970 --- /dev/null +++ b/week-1/test_app/README.md @@ -0,0 +1,19 @@ +********************************* +* A TEST APPLICATION * +********************************* + +Description +----------- +This is a test PHP application. You can upload use it to test your LAMP stack. You can also browse the directory structure to get an idea of how PHP web applications are commonly structured. You can also read this README file to find out the sorts of things that should be included in a README file! + +Author & Contact +---------------- +Sorrel Harriet s.harriet@gold.ac.uk + +Installation Instructions +------------------------- +Upload the application to your web root folder. No further actions needed! + +Configuration Instructions +-------------------------- +There is nothing to configure. diff --git a/week-1/test_app/includes/functions.php b/week-1/test_app/includes/functions.php new file mode 100644 index 0000000000000000000000000000000000000000..906f6b0982459bafc789345f766bff2df93dfdf4 --- /dev/null +++ b/week-1/test_app/includes/functions.php @@ -0,0 +1,5 @@ +<?php + +# Write some helper functions here... + +?> diff --git a/week-1/test_app/index.php b/week-1/test_app/index.php new file mode 100755 index 0000000000000000000000000000000000000000..c9ca050d56ef008df2e793a5e5a3f91890740383 --- /dev/null +++ b/week-1/test_app/index.php @@ -0,0 +1,44 @@ +<?php + +// Code to detect whether index.php has been requested without query string +// If no page parameter detected... +if (!isset($_GET['page'])) { + $id = 'home'; // display home page +} else { + $id = $_GET['page']; // else requested page +} + +$content = ''; + +// Switch statement to decide content of page will go here. +// Regardless of which "view" is displayed, the variable $content will +switch ($id) { + case 'home' : + include 'views/home.php'; + break; + case 'page_2' : + include 'views/page_2.php'; + break; + default : + include 'views/404.php'; +} +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <title>Test Application</title> + </head> + <body> + <ul> + <li><a href="index.php">Home</a></li> + <li><a href="index.php?page=page_2">Page 2</a></li> + </ul> + + <?php + // Display content for requested view. + echo $content; + ?> + + </body> +</html> diff --git a/week-1/test_app/views/404.php b/week-1/test_app/views/404.php new file mode 100644 index 0000000000000000000000000000000000000000..515bef47d466c7f4f4671eb5dc369c5a5fb0b34c --- /dev/null +++ b/week-1/test_app/views/404.php @@ -0,0 +1,6 @@ +<?php + +$content = "<h1>Page not found</h1>"; +$content .= "<p>Sorry, the page you requested could not be found.</p>"; + +?> diff --git a/week-1/test_app/views/home.php b/week-1/test_app/views/home.php new file mode 100755 index 0000000000000000000000000000000000000000..cbf88c641fb7f65a9fc8e6e87ef96052f08f4120 --- /dev/null +++ b/week-1/test_app/views/home.php @@ -0,0 +1,7 @@ +<?php + +$content = '<h1>Hello world!</h1>'; +$content .= '<p>If you\'re reading this, it means you have successfully launched the <b>test app</b>.</p>' + +?> + diff --git a/week-1/test_app/views/page_2.php b/week-1/test_app/views/page_2.php new file mode 100644 index 0000000000000000000000000000000000000000..59f181b0b626a557809d5c7f2f5757d7d23d170d --- /dev/null +++ b/week-1/test_app/views/page_2.php @@ -0,0 +1,3 @@ +<?php +$content = '<h1>Welcome to page 2!</h1>'; +?>