Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Dynamic Web Pages Ch 3 V1.0

814 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Dynamic Web Pages Ch 3 V1.0

  1. 1. Chapter 3 Self-server application & Server-side validation
  2. 2. Self-server Applications <ul><li>These applications are answering a question that would usually be answered by the staff in the tours company. </li></ul><ul><li>An example is how much does it cost to do this tour and another tour. </li></ul><ul><li>We will create a tours calculator, (self-server application). </li></ul>
  3. 3. The tour calculator page - 1 <ul><li>Open the generic_template.php and save as tourprice_processor.php and tourprice.php. </li></ul><ul><li>The two pages are shown on the next slides. </li></ul>
  4. 4. The tour calculator page - 2 tourprice.php Objects names: txtNumberAdults txtNumberChildren cboTourName
  5. 5. The tour calculator page - 3 tourprice_processor.php Calculate link to tourprice.php page Contact link to contact.php
  6. 6. The tour calculator page - 4
  7. 7. The tour calculator page - 5 <ul><li>tourprice.php has the following properties. </li></ul><ul><ul><li>Form </li></ul></ul><ul><ul><ul><li>Name = frm_tourprice </li></ul></ul></ul><ul><ul><ul><li>Action = tourprice_processor.php </li></ul></ul></ul><ul><ul><ul><li>Method = POST </li></ul></ul></ul><ul><ul><li>Table inside the form </li></ul></ul><ul><ul><ul><li>4 rows </li></ul></ul></ul><ul><ul><ul><li>2 columns </li></ul></ul></ul><ul><ul><ul><li>width of 60 percent </li></ul></ul></ul><ul><ul><li>List values </li></ul></ul><ul><ul><ul><li>Highlights of Argentina, 500 </li></ul></ul></ul><ul><ul><ul><li>Highlights of Western Canada, 700 </li></ul></ul></ul><ul><ul><ul><li>Egyptian Pyramids and More, 900 </li></ul></ul></ul>
  8. 8. Calculating the price - 1 <ul><li>Open tourprice_processor.php page. </li></ul><ul><li>Input the php code as shown to; </li></ul><ul><ul><li>declare and initialise the number of adults, kids and tour name. </li></ul></ul><ul><ul><li>Calculate the price of the tour. </li></ul></ul>Check you have the same variable names in your tourprice.php page as those in quotes. Variable declaration
  9. 9. Calculating the price - 2 <ul><li>Now you have calculated the tourprice variable, you need to display it. This is done by placing php script amongst the html code, as shown below. </li></ul><ul><li>Save and view the page. What happens when you don’t put in an amount for the adults or kids? </li></ul>
  10. 10. The calculator so far…. <ul><li>So far the calculator works if numeric values are put in the adults and kids fields. </li></ul><ul><li>Errors appear if not values are placed in the adults and kids fields. </li></ul><ul><li>The next couple of slides are going to add a css rule for errors and trap the error with php code. </li></ul>
  11. 11. Adding new style to the css <ul><li>Add an error style to the css file with the following properties; </li></ul><ul><ul><li>Type: class </li></ul></ul><ul><ul><li>Name: error </li></ul></ul><ul><ul><li>Weight : bold </li></ul></ul><ul><ul><li>Colour : #990000 </li></ul></ul><ul><li>This style will be used if the client makes an error with the information for the tour calculator. </li></ul>
  12. 12. Server-side validation -1 <ul><li>Server-side validation is validating the tourprice.php page variables sent to the tourprice_processor.php page. </li></ul><ul><li>This is done by checking the two form variables for numerical values, as shown. </li></ul><ul><li>If one of them doesn’t hold a numeric value the client is sent back to the tourprice.php page, displaying an error. </li></ul><ul><li>Add the code. </li></ul>
  13. 13. Server-side validation- 2 <ul><li>Once the client is sent back to the tourprice.php page the code to pick up this error is needed. </li></ul><ul><li>This code shows the response to that variable and displays a message to the client. </li></ul>
  14. 14. Lab 3 - 1 <ul><li>In this lab you are to add a list/menu to reservations.php and change the form action to call the page reservations_action.php. </li></ul><ul><li>The two pages are shown on the next slides. </li></ul><ul><li>To have “Yes” or “No” displayed on equipment you will have to write an if statement finding out if the box was ticked, “true” or not ticked, “false”. </li></ul>if (equipment==“true” ) echo “No”; else echo “Yes”;
  15. 15. Lab 3 - 2 reservations.php The value for each label is: 1 for Nepal Track, 2 for Alasken Wilderness, etc.
  16. 16. Lab 3 - 3 reservations_action.php. This page was created from tourtemplate.php. Reservation Information from reservation.php page

×