CS 330 Class 9 - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CS 330 Class 9

Description:

Adding a new option to pizza.htm. Self-referring pages (not covered ... if (isset($_GET['topping'])) //process survey information. drop down to the HTML survey ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 14
Provided by: cshil
Category:
Tags: class | topping

less

Transcript and Presenter's Notes

Title: CS 330 Class 9


1
CS 330 Class 9
  • Programming plan for October 28, 2007
  • Logistics
  • UNIX commands
  • put even your htm files on max
  • option move your homepage to max
  • Homework
  • Debugging
  • Adding a new option to pizza.htm
  • Self-referring pages (not covered in text)
  • Start talking about interfaces to a database

2
Homework
  • guestg.htm calls guestg.php
  • lt?php
  • check to see if this is in response to a
    submission
  • if (isset(_GET'firstName')) //arriving from a
    form submission
  • echo "First Name ". _GET'firstName'. 'ltbr
    /gt'
  • echo "Last Name ". _GET'lastName'. 'ltbr
    /gt'
  • echo "(and so forth)"
  • ?gt
  • Using POST instead of GET guestp.htm
  • lt?php
  • check to see if this is in response to a
    submission
  • if (isset(_POST'firstName')) //arriving from a
    form submission
  • echo "First Name ". _POST'firstName'. 'ltbr
    /gt'
  • echo "Last Name ". _POST'lastName'. 'ltbr
    /gt'
  • echo "(and so forth)"

3
Homework
  • POST versus GET
  • GET limited in maximum length of data
  • POST variables not sent in the header
  • avggrd1.php
  • hidden1.htm
  • what's missing in the response to princess?

4
Homework Unobtrusive JavaScript
  • It is the extra layer above the mark-up "what is
    this text" and
  • the CSS "how should it be displayed." Javascript
    adds a new
  • dimension, the "how should this element behave"
    (ref)
  • document.myform.onsubmit validateform
  • versus
  • ltform name-"myform" onsubmit"validateform()"gt
  • Other aspects
  • put in a separate document
  • graceful degradation (does it work with no
    JavaScript?)
  • "This makes the HTML code neater, allows for an
    easier
  • time updating the functionality of a page, and
    makes it seem
  • like you're more sophisticated (anon.)."

5
Debugging
  • If you can't open a data file, check the
    permissions
  • chmod aw .
  • Echo variables
  • http//max.wells.edu/carol/test/avrgrd_np.php
  • Comment out large sections
  • http//max.wells.edu/carol/test/redirect_np.php
  • Email me
  • Misc can edit from SSH

6
Pizza!
  • Adding a new option to pizza pizza1.htm
  • calls pizza1.php and presults1.php
  • what's the problem here? (new choices not
    presented to the user)
  • pizza1.php
  • find and increment the selected item
  • item_foundfalse
  • count count(options)
  • for (i0 i lt count i)
  • if (optionsi user_selection)
  • item_noi
  • item_foundtrue
  • dataitem_no
  • if (!item_found) //add a new option
  • datacount 1
  • optionscount user_selection

7
Self-Referring Pages
  • So far .htm pages call .php pages.
  • More common practice bundle it all in one page
    which calls
  • itself and is processed differently depending on
    the call.
  • pizzas.php
  • //check to see if the request has variables set
    by the form
  • if (isset(_GET'topping'))
  • //process survey information
  • drop down to the HTML survey

8
Databases and PHP
  • MySQL
  • freeware
  • supported on UNIX and Windows
  • stable but evolving
  • Example Wells Premed
  • users identified by name, password, role. Actions
    restricted by role
  • students enter and maintain their data (password
    protected)
  • advisors view student data and add comments
    (password protected)
  • Example CS 105 management
  • dummy account sstudent with password sstudent

9
Wells Premed Site
  • Student options
  • Register
  • Update registration
  • Advisor options
  • View student data by individual, state, year, all
  • Add comments
  • Database tables
  • tblStudent student registration data
    and password
  • tblAdvisor advisor name and password
    for login
  • tblComments by an advisor wrt a student

10
Wells Premed Site
11
Student Data
Entered and maintained by the student Viewed by
advisors
12
Advisor login
Validated against tblAdvisor
13
Comments Table
Advisor options
Write a Comment
User Comments (0)
About PowerShow.com