note 103528 deleted from tutorial by danbrown

From: Date: Mon, 18 Apr 2011 17:54:06 +0000
Subject: note 103528 deleted from tutorial by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178951@lists.php.net to get a copy of this message
Note Submitter: Connie Hecker ---- PHP is very easy. lol PHP Forms LESSON #2 - Practice 2 1. Open the php02form.html page in Crimson editor and Save As BuildForm.html. Next, open the php02.php file and Save As AcceptForm.php. 2. Each of these files will still use the php.css style sheets. Now, edit the BuildForm.html page. a. Leave the Name: text box at the top of the form. b. Edit the radio buttons to read Part-time and Full-time, re-name their field empType. c. Create a new Text box called payRate with a label called Pay Rate on a new line. d. Create another called fedTax, labeled Federal Tax Rate on a new line. e. Another called stateTax, labeled State Tax Rate on a new line. f. Create a Select box, with the label Bonus Amount. Put the values: 100, 50, 25 and 0 to select from. Review your book, chapter 9 (page 347) to help create the select box on your form. g. Make sure to leave the submit button, change the name of the file that it calls. h. Save, test and validate form file. Adjust the styles to match your own taste preferences. Make sure to use the class most appropriate for this form or create a new one. Of course, if you hit submit, you will get an error since the called .php file has not been edited to accept the new fields sent in the _Post array. 3. So, lets edit the .php file to accept the values entered into the newly created form. a. Edit the AcceptForm.php to accept all fields being sent to it from the $_Post array into its own variables. You can name them the same as they are named in the Form page or make up your own new variable names. b. Keep the line displaying the name. c. Display the following: I am a Full-Time (or Part-Time) employee. d. Next, you can re-use the code you wrote from Practice #1 to calculate the Gross pay, Fedtax, Statetax, then net pay. Write php code to display the values like you did in Practice #1. Remember this: My total pay is ________ I paid _________ in federal taxes. I paid ________ in state taxes. My paycheck is $_______ this week. e. Now, add the bonus amount to the paycheck amount. Write php code to display the following on your page: I made $_______ in bonus dollars this week. This makes my total take home pay $_______. f. Save, test and validate page. Always test your results. Using a calculator, enter the same values entered into your form, perform the calculations with your calculator. Do the results match???? If not, one or the other was not done correctly. ALWAYS make sure your logic is working correctly!!! Re-work your code until you are positive that all possible calculations are being done properly. g. Look at the code from your web browser by selecting "View Source". Compare this xhtml code that was sent to your browser with the .php file that you actually wrote. Make sure you understand how the php code was rendered before it was sent to the browser. Great Job!!!! For the first time, you have accepted raw data from your user, processed it and sent it back to your user as information!!! Send me your url for this inclass work for pass/fail credit.

« previous php.notes (#178951) next »