INSY431 Internet Programming II PDF
Document Details
Uploaded by FasterMountain8186
St. Mary's University
Tags
Summary
This document is an overview or lecture notes about Internet Programming II, focusing on Server-Side Programming using PHP. The document covers introduction to PHP, installation, basics, functions, object-oriented aspects, and interactions with MySQL. It also includes discussions on advanced concepts like file handling, cookies, and sessions.
Full Transcript
St. Mary’s University Faculty of Informatics INSY431 Internet Programming II Server-Side-Scripting Server Side Programming with PHP 2 Chapter One What we'll cover Introduction to PHP Installation of PHP PHP Basics PHP Function...
St. Mary’s University Faculty of Informatics INSY431 Internet Programming II Server-Side-Scripting Server Side Programming with PHP 2 Chapter One What we'll cover Introduction to PHP Installation of PHP PHP Basics PHP Function OOP in PHP PHP and MySQL Arrays Sessions Advanced concepts in PHP – Working with Files – Cookies and Sessions 4 Introduction to PHP What You Should Already Know Before you continue you should have a basic understanding of the following: – HTML – CSS – JavaScript What is PHP? PHP is an acronym for "PHP Hypertext Preprocessor“ PHP is a server scripting language, and is a powerful tool for making dynamic and interactive Web pages quickly PHP is a widely-used, open source scripting 5 Intro…. What is a PHP File? PHP files can contain text, HTML, CSS, JavaScript, and PHP code PHP code are executed on the server, and the result is returned to the browser as plain HTML PHP files have extension ".php" What Can PHP Do? PHP can generate dynamic page content PHP can create, open, read, write, and close files on the server PHP can collect form data PHP can send and receive cookies PHP can add, delete, modify data in your database PHP can restrict users to access some pages on your website PHP can encrypt data 6 With PHP you are not limited to output HTML. You can Intro…. Why PHP? PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP supports a wide range of databases PHP is free. Download it from the official PHP resource: www.php.net PHP is easy to learn and runs efficiently on the server side 7 Intro… PHP is particularly strong in its ability to interact with databases. PHP handles connecting to the database and communicating with it. You tell PHP the name of the database and where it is, and PHP handles the details. Major databases currently supported by PHP include the following: – dBASE, Informix, Ingres, Microsoft SQL Server, mSQL, MySQL, Oracle, PostgreSQL, Sybase PHP supports other databases as well, such as filePro, FrontBase, and InterBase. PHP also supports ODBC (Open Database Connectivity), a standard that allows you to communicate with even more databases, such as Access. PHP works well for a database-driven Web site. 8 Client vs Server Side Server-side Web scripting is mostly about connecting Web sites to back end servers, such as databases. Server to client: Web pages can be assembled from back end- server output. Client to server: Customer-entered information can be acted upon. 9 Database Driven Web Application A database web application is an application based on World Wide Web (Internet) and database using web browser as a client. Traditional client-server (2-tier architecture): A client computer handles the user interface (Access Forms, Oracle Forms, Reports) and a database server stores the data. The actual functionality (business logic) of the application resides on the client and/or in the databases Web-based (multi-tier architecture): A client computer uses a browser to access information from two or more servers (web servers, application servers, database servers) (i.e.) A web server handles web requests, an application server handles dynamic requests and a database server stores the data) Application Clients Servers Database including web Server servers 10 Three-Tier Architecture 11 Software Requirements To work with PHP, you need to install a web server, PHP, and database server. There are many web servers to choose from; the most commonly used web server is called Apache which you can download from the internet freely. Similarly, for database, there are many options to use; the most popular database server for web pages is MySQL. PHP is also available freely on the Internet. You can download each of the above three software independently and integrate them by configuring Apache and PHP to get them work together. Software producers integrate the three software and offer them as bundle. One such bundle that contains Apache, PHP, and MySQL is Vertrigo, XAMPP and WAMP. All are free software that you can download from internet and install on your computer. Once you install XAMPP, WAPP or Vertrigo, you have all the necessary things to write server side scripting with PHP. 12 AMP One of the most powerful development models for the Web has been the notion of “AMP.” AMP stands for “Apache / MySQL / PHP & Perl working together.” Apache is the MySQL is a PHP / Perl is a industry- very popular general leading web database purpose server that that runs on scripting runs a most environment majority of operating widely used web servers systems. for building on the dynamic web Together, Together, they Internet.they form form the the nucleus nucleus of of a a web web application application sites. system. system. www.easyphp.org -> contains the software needed for all three packages. You can install and configure very easily. 13 Apache - Benefits Apache is well supported - Most support for Apache is free and available 24 hours a day via Internet mail or newsgroups. Apache is multi-platform - Apache can run on virtually any hardware platform (from PCs to mainframes), and almost any operating system, such as Linux, Windows, NetWare, Macintosh, xBSD, etc. Apache is secure - security holes are rare but when they exist they are discovered and fixed quickly Apache is extensible - anyone can write modules that easily plug in to Apache. If Apache doesn't do what you want or need it to do, anyone with programming skills can write the modules you need. Apache is database-friendly - you can interface Apache with virtually any commercial database, such as Oracle, Sybase, DB2, and Informix, as well as free databases such as MySQL and Postgres. Apache is hardware-friendly - Apache generally consumes far fewer hardware resources that commercial web servers. No Microsoft Viruses - Apache is immune to the Code Red, Nimda, and 14 other viruses that target at Microsoft Web servers.