Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PHP arrays! a. Modify the index.php file so it starts a session that lasts for 1 year. b. Modify the index.php file so it stores

PHP arrays!

a. Modify the index.php file so it starts a session that lasts for 1 year. b. Modify the index.php file so it stores the array of tasks in the session. c. Modify the task_list.php file so it does not store the array of tasks in hidden HTML fields. d. Test this application. Make sure to exit and restart the browser to make sure the session is persistent.

CODE:

index.php

switch( $action ) { case 'add': $new_task = filter_input(INPUT_POST, 'newtask'); if (empty($new_task)) { $errors[] = 'The new task cannot be empty.'; } else { $task_list[] = $new_task; } break; case 'delete': $task_index = filter_input(INPUT_POST, 'taskid', FILTER_VALIDATE_INT); if ($task_index === NULL || $task_index === FALSE) { $errors[] = 'The task cannot be deleted.'; } else { unset($task_list[$task_index]); $task_list = array_values($task_list); } break; }

include('task_list.php'); ?>

task_list.php

Task List Manager

Task List Manager

0) : ?>

Errors

Tasks

There are no tasks in the task list.

    $task) : ?>

Add Task

0) : ?>

Delete Task

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

4. Explain why strategic planning is important to all managers.

Answered: 1 week ago