Course Topics

2y ago
20 Views
2 Downloads
264.15 KB
15 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Sasha Niles
Transcription

IT360: Applied Database SystemsIntroduction to PHPChapter 1 and Chapter 6 in "PHP and MySQLWeb Development"Course Topics SQLRelational modelNormalizationDatabase designPHPMySQLDatabase administrationTransaction ProcessingData Storage and Indexing1

The Three-Tier ArchitecturePresentation tierClient Program (Web Browser)Middle tierApplication ServerData managementtierDatabase ManagementSystem, File ServerExample 1: Airline reservationsBuild a system for making airline reservations Database System Application Server Client Program2

TechnologiesClient Program (Web Browser)Application ServerDatabase ManagementSystemHTML, Javascript, XSLTC , Cookies, XML,XPath, web services,Perl, PHPSQL, Triggers,Stored ProceduresWeb Applications Need to choose: Operating systemWeb server softwareDatabase Management SystemProgramming or scripting language3

PHP PHP: PHP Hypertext Preprocessor Server-side scripting language PHP pages require a web server with PHPsupport Competitors:PHP Strengths High performanceInterface to many different database systemsBuilt-in librariesEase of learning and useObject-oriented supportPortabilityOpen sourceFreeAvailability of support4

PHP References Online references http://www.php.net Online Tutorial http://www.w3schools.com/php/default.asp PHP and MySQL Web Development byLuke Welling and Laura Thomson IT350 textbook: Internet & WWW How ToProgram by Deitel, Deitel, and GoldbergCGI – What does it all look like?5

IT350 - CGI Script Basics Common Gateway Interface (CGI) “Common”: Not specific to any operatingsystem or language Output file generated at runtime:1. When a program executed as a CGI script,“standard output” is redirected to client Webserver2. Web server then redirects output to client'sbrowserIT350 - How can CGI get datafrom user?Technique #1: Forms User enters data via a form, submitsForm directs results to a CGI programScript receives data in one of two ways:1. Method “GET”2. Method “POST”Use language-specific method to get these inside CGIprogramTechnique #2: URL with parameters a href http://www.cs.usna.edu/calendar/view.php?events seminars Seminars /a 6

Form ProcessingPHP Overview PHP tags ?php? Mixed with HTML tags File extension .php Statements Separated by semicolon if.else., while, do, for, switch Variables varname Type determined by content; variables not declared; case sensitive Strings Single quotes – literal string Double quotes – interpolated string (variables are replaced with theirvalue) Accessing form variables POST[‘age’], GET[‘age’], REQUEST[‘age’]7

PHP Overview PHP objects Java-like inheritancepublic, private, or protected attributes and methodsconstruct(), destruct(),set(), get() PHP functions function myFunction( param1, param2){ } Files resource fopen(string fileName, string mode)int fwrite(resource handle, string someText)int fclose(resource handle)string fgets(resource handle)boolean feof(resource handle)How everything works:Step 1: Input Form – form.html ?xml version "1.0" ? !DOCTYPE html PUBLIC "-//W3C//DTD XHTML dtd" html head title IT360 PHP test page /title /head body form action "processPersonInfo.php" method "post" p label Enter your name: input type "text" name "name"/ /label /p p label Enter your age: input type "text" name "age" / /label /p p input type "submit" name "submit" value "Submit"/ /p /form /body /html 8

?phpclass Page{page.inc.php//attributespublic content;private title;private header " ?xml version '1.0' ? !DOCTYPE html PUBLIC '-//W3C//DTD XHTML dtd' ";//constructorpublic function construct( title){ this- title title;}//set public attributespublic function set( name, value){ this- name value;}//display pagepublic function display(){echo this- header;echo " head title this- title /title /head ";echo " body ";echo this- content;echo " /body /html ";}} //end class definition? Step 1 version 2 –getPersonInfo.php ?php//bring in the class definitions,//so we can use themrequire('page.inc.php');//create a new page object page new Page("Input person");//set the content: in needs to be a form page- content ' form action "processPersonInfo.php" method "post" '.' p label Enter your name: input type "text” name "name“/ /label /p ’.‘ p label Enter your age: input type "text" name "age"/ /label /p ’.' input type "submit" value "submit" ';//display the page page- display();? 9

person.inc.php – part 1 ?php/* define a class Person with name and age */class Person{private name;private age;//constructorpublic function construct(){}//default set function invoked when the private fields are set//this is a good place to do sanity/security checkspublic function set( varName, varValue){ varValue trim( varValue); varValue strip tags( varValue);if (!get magic quotes gpc()){ varValue addslashes( varValue);} this- varName varValue;}//default get function - nothing special for nowpublic function get( varName){return this- varName;}person.inc.php – part 2//return a string that contains the HTML code to get data for a personpublic static function getPersonAttributesAsHTMLInput(){ myString ' p label Enter your name: input type "text"name "name"/ /label /p p label Enter your age: input type "text" name "age"/ /label /p ';return myString;}//process the person info to insert to file and display confirmationpublic function processPerson() {//write this person to the default file success this- insertToFile();//return a confirmation messageif ( success){ confirmation ' h1 Thank you for registering with oursite /h1 '.' p The information recorded is as follows: br/ '."Name: this- name br / Age: this- age /p ";}else{ confirmation ' h1 Error: we had problems with yourregistration (probably some file error - permissions?).Please try again. /h1 ';}return confirmation;}10

person.inc.php – part 3/* save the content to a specified fileor "persons.txt" if nothing is specified */private function insertToFile( fileName "persons.txt"){ fp @fopen( fileName, 'a');if (! fp){return false;}else{ text " this- name\t this- age\n";fwrite( fp, text);fclose( fp);return true;}}person.inc.php – part 4/*read all info from file and return it in some nice format */public static function getAllPersonsInfo( fileName "persons.txt"){//read the data from file and construct the content fp @fopen( fileName, 'r');//check for errorsif (! fp){ content " p ERROR! Could not open file fileName forreading. /p ";}//if everything OK, read the fileelse{ content ' p Here is the list: br / ';//read one line line fgets( fp);while( !feof( fp) ){//process the line content . line . ' br / ';//read next line line fgets( fp);} content . ' /p ';//close the filefclose( fp);}return content;}}? 11

?phpStep 2 processPersonInfo.php//bring in the class definitions,require('page.inc.php'); require('person.inc.php');//get the params sent by the form name POST['name']; age POST['age'];//create a new page object page new Page("Registration confirmation");//check that input params okif (empty( name) empty( age)){ page- content ' p Name or age not entered!! Try again /p '; page- display();exit;}//create a new person with these properties dummy new Person(); dummy- name name; dummy- age age;//set the content: the confirmation message returned by the processPersonmethod for this person; all work is done inside processPerson page- content dummy- processPerson();//display the page page- display(); ? ?php//bring in the class definitions,//so we can use p');Step 3: readPearsonsInfo.php//get the input params (from URL)if (isset( GET['filename'])){ fileName GET['filename'];}else{ fileName "persons.txt";}//create a new page object page new Page("Persons list");//set the content: the confirmation message returned by theprocessPerson method for this person//all work is done inside getAllPersonsInfo page- content Person::getAllPersonsInfo( fileName);//display the page page- display();? 12

Class Exercise Modify getPersonInfo.php to use thegetPersonAttributesAsHTMLInputmethod in Person classClass Exercise Create a PHP script that accepts aparameter called number from the addressbar and prints back the English word forthe decimal value (assume number isbetween 1 and 5). You should create firsta file that looks like this, and read from it:OneTwoThreeFourFive13

PHP Summary PHP tags ?php? Mixed with HTML tags File extension .php Statements Separated by semicolon if.else., while, do, for, switch Variables varname Type determined by content; variables not declared; case sensitive Strings Single quotes – literal string Double quotes – interpolated string (variables are replaced with theirvalue) Accessing form variables POST[‘age’], GET[‘age’] (if method is GET), REQUEST[‘age’]14

PHP Summary PHP objects Java-like inheritancepublic, private, or protected attributes and methodsconstruct(), destruct(),set(), get() PHP functions function myFunction( param1, param2){ } Files resource fopen(string fileName, string mode)int fwrite(resource handle, string someText)int fclose(resource handle)string fgets(resource handle)boolean feof(resource handle)15

PHP: PHP Hypertext Preprocessor Server-side scripting language PHP pages require a web server with PHP support Competitors: PHP Strengths High performance Interface to many different database systems Built-in libraries Ease of learning and

Related Documents:

STD: 11 English (FL) (SCIENCE & GENERAL) * Unit Prose Poetry Supplementary Reader Grammar Section Writing section Topics to be included Topics to be Excluded for 20-21 Topics to be included Topics to be Excluded for 20-21 Topics to be included (For Self Study Only) Topics to be Exclu

Topics: Clipper, clamper, and voltage multiplier circuits Questions: 1 through 10 Lab Exercise: Diode clipper circuit (question 51) Day 2 Topics: Thyristor devices Questions: 11 through 20 Lab Exercise: Work on project Day 3 Topics: Thyristor power control circuits Questions: 21 through 30 Lab Exercis

Parallel Gibbs Sampling [aaim 09] Inputs: 1. training data: documents as bags of words h b f words topics 2. parameter: t e num er o topics Outputs: 1 by product: a co occurrence docs docs. ‐ ‐ matrix of topics and documents. 2. model parameters: a co‐ words topics occurrence matrix of topics and words.

Table 2.1 : Pesticide Sa fety Training Topics Qualified Trainers Presentat ion Training Records Previously Trained Empl oyees Chapter 3 - Pestic ide Safety Training Topics Pesticide Worker Safety Regulation Training Topics Table 3.1 : Pesticide Safety Training Topics Effective March 1, 2018 Chapter 4 - Training Topics for Fieldworkers and .

CAM Topics: The most commonly communicated CAM topics are similar yearover year. At the individual issuer level, CAM topics are the same for 79% of LAFs with the same number of CAMs in years 1 and 2. Auditors of issuers in certain industries concentrate CAM communications on specific topics and often repeat those topics yearover year.

General Biology I (BSC-1010) Syllabus COURSE INFORMATION Course Title General Biology I Course Number BSC-1010 Course Discipline Biology Course Description In this course students will cover topics such as biomolecules, cells, energy flow, genetics, and physiology. Note: This course is designed for science and biology majors. It will be very

Course Schedule The course schedule section contains a detailed plan of the course topics, readings, and activities. It is the same as the course schedule contained in this syllabus. Syllabus This syllabus section contains the syllabus, a detailed document about the course with topics to be covered, required reading and

This Course Key is similar to the course reference number you used to register for FIN 3403 this semester. Course keys from previous semesters cannot be used for this semester’s course. Other Course Materials: Pedagogical (Helpful) Materials—useful materials for this course are available on the course webpage,