Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP ASAP...I cant figure this out....PHP...I have the time and date working but not the cookies. Chapter 2 Future Value Files (Zip file).zip (7.656

PLEASE HELP ASAP...I cant figure this out....PHP...I have the time and date working but not the cookies.

  • image text in transcribed Chapter 2 Future Value Files (Zip file).zip (7.656 KB)

Background

Referencing examples in Chapter 12, you will:

  1. Enhance the Chapter 2 Future Value application to demonstrate your knowledge of working with PHP sessions and cookies
  2. Upload the folder of application files to your WEB182 directory on the wcet3.waketech.edu server

Instructions

This assignment MUST be completed as part of your Lesson 8 assignments by or before 3/3/19 @ 11:59pm.

1. Using the attached example files (same as the textbook files), install the Future Value applicationdescribed on pp. 80-87 of your textbook. (Remember, this is a complete, working PHP application.)

2. In the file display_results.php, add PHP code to display the following message after the Future Value output:

"This calculation was done on $date at $time." (Note: the day/time should be EST)

3. Modify this application so it uses a persistent session to save the last values entered by the user for 5 minutes. (1)

3. Upload your future_value folder to the wcet3.waketech.edu server

4. Test your application to make sure it is working properly. Include the following for this assignment submission:

  1. A clickable URL to your PHP file on wcet3.waketech.edu (2)

Notes:

(1) The following hints will help you modify this application

  • This application is not built using an MVC pattern, so it should be easier to make the few modifications needed.
  • In index.php:
    • At the top of the file (before the DOCTYPE html line) you will need to add a section of code which checks to see if a session id exists. If it does not, the code you add (which will be similar to the example on page 359) will need to start a session.
    • After the above code (and before the DOCTYPE html line) you will need to add a section of code which checks to see if any of the (3) inputs (amount, rate, & years) already exist in $_SESSION[ ]. If they do, you will need to set the initial values for the form fields to those values.
  • In display_results.php:
    • At the top of the file you will need to make sure you start the session (see page 358).
    • After the input field values (amount, rate, & years) are error checked, you will need to store the values in the session (see pp. 360-361)
    • Remember to display the day/time when your calculation was performed.

index.php-

//set default value of variables for initial page load if (!isset($investment)) { $investment = ''; } if (!isset($interest_rate)) { $interest_rate = ''; } if (!isset($years)) { $years = ''; } ?>

Future Value Calculator

Future Value Calculator

Investment Amount: value="

">

Yearly Interest Rate: value="">

Number of Years: value="">

display_results.php-

// get the data from the form $investment = filter_input(INPUT_POST, 'investment', FILTER_VALIDATE_FLOAT); $interest_rate = filter_input(INPUT_POST, 'interest_rate', FILTER_VALIDATE_FLOAT); $years = filter_input(INPUT_POST, 'years', FILTER_VALIDATE_INT); // validate investment if ($investment === FALSE ) { $error_message = 'Investment must be a valid number.'; } else if ( $investment 30 ) { $error_message = 'Years must be less than 31.'; // set error message to empty string if no invalid entries } else { $error_message = ''; }

// if an error message exists, go to the index page if ($error_message != '') { include('index.php'); exit(); }

// calculate the future value $future_value = $investment; for ($i = 1; $i

// apply currency and percent formatting $investment_f = '$'.number_format($investment, 2); $yearly_rate_f = $interest_rate.'%'; $future_value_f = '$'.number_format($future_value, 2); ?>

Future Value Calculator

Future Value Calculator

Investment Amount:

Yearly Interest Rate:

Number of Years:

Future Value:

This calculation was done on echo "" . date("m/d/Y") . " "; ?> at date_default_timezone_set("America/New_York"); echo " " . date("h:i:sa"); ?>.

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

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

Students also viewed these Databases questions

Question

What is the Treynor performance measure for portfolio P?

Answered: 1 week ago

Question

Is there any evidence that contradicts this statement?

Answered: 1 week ago