Dynamic Web Pages Ch 9 V1.0


Published on

Published in: Technology, Design
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Dynamic Web Pages Ch 9 V1.0

  1. 1. Chapter 9 Using Session variables, hidden fields & inserting data.
  2. 2. Overview <ul><li>In this chapter you will </li></ul><ul><ul><li>Create restricted administration pages. </li></ul></ul><ul><ul><li>Use Session variables </li></ul></ul><ul><ul><li>Use hidden fields </li></ul></ul><ul><ul><li>Insert records into a table. </li></ul></ul>
  3. 3. Creating an Insert Journal Pg -1 Open the generic_template.php. Save as journalAdd.php. Change the page as shown above.
  4. 4. Insert a record <ul><li>On the journalAdd.php page and select the “Insert Record” as shown. </li></ul><ul><li>The next slide shows the screen that appears. </li></ul>
  5. 5. Inserting a record <ul><li>Notice that the JournalID field needs a value. </li></ul><ul><li>This value needs to be increased by one. </li></ul><ul><ul><li>Eg: last value is 3 the next value needs to be 4. </li></ul></ul>
  6. 6. Adding a recordset to find the id value <ul><li>Create this recordset to find the largest number. </li></ul>
  7. 7. Creating a new journal ID <ul><li>Find the recordset code as shown above. </li></ul><ul><li>Add lines 61 & 62. </li></ul><ul><li>These lines obtain the highest id and add one to it. </li></ul>
  8. 8. Storing the id in the form. <ul><li>Add a hidden textfield in the form as shown. </li></ul><ul><li>Write the value as shown. This is the value of the new id that was calculated at the top of the page on the previous slide. </li></ul>
  9. 9. Placing the insert record script <ul><li>Double click on the insert record made earlier and add the new id as the journalID. </li></ul>
  10. 10. Session Variables
  11. 11. Creating a Session variable <ul><li>Create a basic page as shown with a textfield and button in a form. </li></ul><ul><li>Create a new page and call it createsession.php. </li></ul><ul><li>Link the form to the createsession.php page. </li></ul>
  12. 12. Creating a Session variable - 2 <ul><li>To create a session variable the session_start() function must be the 1 st line in the document. </li></ul><ul><li>Then declare and initialise the variable as shown below. Post from the page before. </li></ul>
  13. 13. Creating a Session variable - 3 <ul><li>Create the page below, starting the session and then displaying it. </li></ul><ul><li>Create a link on the createsession.php to this page. This is show on the previous slides. </li></ul>
  14. 14. Classes in php
  15. 15. Creating A Class <ul><li>Classes are similar to Java and actionscript. </li></ul><ul><li>A class has a constructor or a default on is added at compilation time. </li></ul><ul><li>Below is the start of a person class. </li></ul><ul><li>This class is to hold the info about the people that log into the following pages. </li></ul>Name of the class and file name must be identical. Declaring variables. Constructor must be identical to the class name.
  16. 16. Creating a Class -2 <ul><li>The gets and the sets. </li></ul><ul><li>The close of the class </li></ul><ul><li>The close of the php tag. </li></ul>
  17. 17. Using the class to store variables <ul><li>The next couple of slides show the code to create a session variable so it can store an array of objects. </li></ul><ul><li>These objects are created using the Person class. </li></ul>
  18. 18. Using the class to store variables-2 <ul><li>A login page to start the session variable. </li></ul>
  19. 19. Using the class to store variables-3 <ul><li>The design view of the add people page. </li></ul>
  20. 20. Using the class to store variables-4 <ul><li>The php code. </li></ul>The include statement allows access to the Person class.
  21. 21. Using the class to store variables-5 <ul><li>The html code on the page. </li></ul>
  22. 22. Using the class to store variables-6 <ul><li>How to view the data in the class. </li></ul>
  23. 23. Using the class to store variables-7 Table headings. Obtaining the number of objects in the array. Getting each variable for each object. Placing each variable in the table
  24. 24. Using the class to store variables-8 <ul><li>These files can be found a zipped folder called classes.zip on myChisholm. </li></ul>