'', 1 => 'Home', 2 => 'About myself', 3 => 'What I\'ve done so far', 4 => 'Who I would like to be', 5 => 'Webform contact' ]; if ( ! isset ( $_POST ['section'] ) ) { $requested_section_title = 'Home'; } else { if ( ! in_array ( $_POST ['section'], array_keys( $section_page_titles ) ) ) { $page_content_array = [ 'status' => 400, 'errorCode' => 'Bad Request', 'errorText' => 'Requested section \'' . $_POST [ 'section' ] . '\' does not exist: do not attempt to compromise the website.', ]; $page_content_json = json_encode ( $page_content_array ); header('Content-Type: application/json'); echo $page_content_json; exit; } $requested_section = $_POST ['section']; if ( $requested_section == 0 ) { if ( isset ( $_SESSION [ 'section' ] ) ) { $requested_section = $_SESSION [ 'section' ]; } else { $requested_section = 1; } } $_SESSION [ 'section' ] = $requested_section; $requested_section_title = $section_page_titles [ $requested_section ]; $section_templates = [ 1 => file_get_contents ( 'templates/home.phtml' ), 2 => file_get_contents ( 'templates/description.phtml' ), 3 => file_get_contents ( 'templates/projects.phtml' ), 4 => file_get_contents ( 'templates/ideas.phtml' ), 5 => file_get_contents ( 'templates/contact-form.phtml' ), ]; $page_content_array = [ 'status' => 200, 'pageTitle' => $requested_section_title, 'html' => $section_templates [ $requested_section ] ]; $page_content_json = json_encode($page_content_array); header('Content-Type: application/json'); echo $page_content_json; exit; } ?> <?=$requested_section_title?> | Bryan Pedini