Website Development - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Website Development

Description:

An Exercise: Interest Compounding. Refer to the handout. Now: PHP standalone page (compound.php) ... making the compounding calculator dynamic. Now, the Form ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 16
Provided by: Econ82
Category:

less

Transcript and Presenter's Notes

Title: Website Development


1
Website Development Management
CIT 3353 -- Fall 2005 www.clt.astate.edu/jseydel/m
is3353
  • Elementary Exercises with PHP

Instructor John Seydel, Ph.D.
2
Student Objectives
  • Upon completion of this class meeting, you
    should be able to
  • Set up root directory for Apache localhost
  • Work with user-defined local variables
  • Recognize PHP superglobals
  • Use various operators in PHP
  • Apply some simple PHP functions

3
Lets Do Some Reorganizing
  • Open up IE to http//localhost
  • Should display standard Apache start page
  • Shows if no index.html exists in the root
    directory
  • Open up Windows Explorer to the Apache default
    root directory
  • C\Program Files\Apache Group\Apache2\htdocs
  • Create a subdirectory OriginalFiles
  • Move all existing files into OriginalFiles
  • Copy all files from webroot directory in My
    Documents into htdocs
  • Create a desktop shortcut to htdocs
  • Refresh your browser window
  • Your index.html should now display
  • If none, then a directory listing should display

4
An Exercise Interest Compounding
  • Refer to the handout
  • Now PHP standalone page (compound.php)
  • Later Form page enhancement (compound.html)
  • Open PHP Designer
  • Close all PHP Designer windows
  • Set options
  • Create new PHP document
  • Apply XHTML DTD and modify
  • Create multi-line document type declaration
  • Add xmlns attribute to lthtmlgt tag
  • Create the PHP script to write the XML
    declaration test the page
  • Create the PHP script for variable assignments
    test the page
  • Write the HTML (without PHP) to form the body
    test the page
  • Add the PHP scriptlets to complete the body test
    the page
  • Post to the SuSE1 server (/exercises) and test
    the page

5
Variables Constants
  • User-defined variables
  • Local exist only within given procedure
  • Global must be declared
  • PHP superglobals
  • _POST . . .
  • _GET . . .
  • _COOKIE . . .
  • _SESSION . . .
  • Constants
  • Essentially are variables that cannot be changed
    once theyre defined
  • Require declaration using define() function

6
Typical PHP Operators
  • Arithmetic - /
  • Concatenation .
  • Assignment
  • -
  • .
  • Comparison ! gt lt gt lt
  • Logical

7
Enhancing the Application
  • We need a form page to serve as a front-end
  • Create a new file, compound.html
  • Use PHP Designer
  • Follow the code in the handout
  • This will be the form that provides the values
    assigned to the variables
  • Were thus making the compounding calculator
    dynamic

8
Now, the Form Processor
  • Open compound.php and save as compound_proc.php
  • Insert the following between lines 4 and 5
  • dblYears _POST'txtTerm'
  • dblInterest _POST'txtIntRate'
  • if ((dblYears lt 0) (dblYears gt100))
  • header("Location compound.html")
  • Now, submit the form (compound.html)
  • First with reasonable data
  • Then without data
  • Comment out original variable assignments
  • Use // for single lines
  • Or use / . . . / for multiple lines
  • Post to the SuSE1 server

9
A Review of Todays Concepts
  • Variable naming
  • Naming start with and use correct prefix
  • Types int, dbl, str
  • Commenting PHP code
  • PHP functions print(), echo(), pow(), define(),
    header()
  • PHP superglobals _POST . . .
  • Operators
  • Arithmetic
  • Assignment .
  • Logical
  • Control structures selection (if)
  • Using the escape designator \

10
Summary of Todays Objectives
  • Set up root directory for Apache localhost
  • Work with user-defined local variables
  • Recognize PHP superglobals
  • Use various operators in PHP
  • Apply some simple PHP functions

11
Appendix
12
Structure for Websites (Server)
  • www.SuSE1.AState.edu
  • index.html
  • exercises.html
  • /images
  • LogoASU.gif
  • . . .
  • /exercises
  • /chapter4
  • errorscript.php . . .
  • firstscript.php
  • phptag.php
  • . . .
  • /chapter5
  • . . .

13
Structure for Local Disks
  • C\Documents and Settings
  • \sstudent
  • \My Documents
  • \sstudent
  • index.html
  • exercises.html
  • \images
  • LogoASU.gif
  • . . .
  • \exercises
  • \chapter4
  • errorscript.php . . .
  • firstscript.php
  • phptag.php
  • . . .
  • \chapter5
  • . . .

14
Some Guidelines for Source Code
  • Use lowercase for tags attributes
  • Quote attribute values
  • Use relative references for resources on same
    server
  • Always use closing tags
  • Nest elements properly close in reverse order of
    opening
  • Use indentation consistently and to make code
    readable
  • No more than 80 characters per line of code
    break long tags into multiple lines, typically
    one per attribute
  • Avoid deprecated elements, e.g., ltfontgt, ltigt, ltbgt
  • Use no spaces in file names
  • Treat all URLs and other resource names as if
    case-sensitive

15
Browser/Server Interaction
Write a Comment
User Comments (0)
About PowerShow.com