Lab 4
PHP Redux, Sticky Forms, and Email

1. Complete your Chapter 3 Web site's Date Form and Register pages, following the examples from the book.

2. For the Calculator page... (you didn't think you'd get out of one of my courses without having to do an Investment Calculator, did you?)... you're going to program a simple investment calculator (surprised?)!

3. Use the following function (which you can copy and paste into your page):

function calculate_future_value ($monthly=100.0, $rate=0.10, $numyears=30){
	$total = 0;
	for ($counter=1; $counter <= $numyears*12; $counter++) {
		$total*=1+$rate/12;
		$total+=$monthly;
	}
	return $total;
}

4. If a person has not submitted any values (or at least a monthly amount), show a nicely formatted form asking for a monthly investment amount(100.0 for $100.00), an annual rate of return (such as 0.10 for 10%), and a number of years to simulate investing (how many years to retirement). Label the Submit button "Calculate".

5. If values have been submitted, display something like the following:

Investing $100.00 per month at an annual rate of 10.0% for 30 years, you'll retire with $226,048.79.
Would you like to try a different investment scenario?

And, display the form with their previous entries already filled in.

For a sample, working version of the calculator, go to http://iscm.gcsu.edu/~bpayne/ch3/calculator.php

[Options: Set the cursor flashing in their Monthly Investment Amount textbox each time the page is loaded.]


©2005 - Bryson R. Payne, Ph.D. - All rights reserved.