On October 23rd, 2014, we updated our
By continuing to use LinkedIn’s SlideShare service, you agree to the revised terms, so please take a few minutes to review them.
There’s often no one ‘correct’ way to design a web application, though some approaches will probably be more appropriate than others.
In this class
PHP & MySQL
PHP for dynamic web page
creation, and MySQL
for basic database tasks
Static Vs. Dynamic
The most basic web sites are ‘static’; they are composed of flat text HTML files living on a server
The client (browser) requests the file, and software on the server sends the unmodified file to the client. Easy, simple, and not really a ‘web application’.
User types ‘www.google.com’ into their browser
Browser looks up the domain name, then sends the request to the appropriate server
Software running on server loads the requested file and sends it back to the client
Client receives the file and displays it in the browser
Static Transaction Components
Browser (Internet Explorer, Firefox, Safari) and operating system
DNS system, HTTP (Hypertext Transport Protocol)
Apache or IIS web server software, underlying server operating system
Browser rendering HTML
Client Side Components
Web browsers are pieces of software that understand HTML markup language (among other things)
DNS is typically handled by the client operating system, connected to a DNS server, and resolves domain names to IP addresses
Browsers can use the operating system to send out HTTP requests
Server Side Components
Servers usually run on more sophisticated versions of standard operating systems. Windows has a server version, OS X has a server version, and Linux is a full-fledged server operating system
Servers run web server applications such as Apache or Windows IIS. These applications take care of receiving client requests, finding the requested resources, and returning them to the clients (among other things)
Limitations of Static Web Pages
Static web pages are a ‘one size fits all’ proposition. Everyone has access to the same set of pages.
Static would make for horrible online banking, ecommerce, web-based email...
Adding dynamic processing
By adding application logic to the server, we’re able to customize our response to each client request
Allows us to have a ‘conversation’ with each client based on data sent by the client, data stored on the server, and information exchanged during the ‘conversation’
And that’s where PHP comes in
PHP stands for “PHP: Hypertext Preprocessor”. (Yes, the name is recursive)
Allows us to add programming logic to our HTML pages, processed by our server application(s), that can produce custom HTML on demand.
What’s happening on the server
Incoming HTTP request is received by Apache
The HTTP request is for a PHP file
Apache loads the PHP file and runs it through the PHP parser (application running on the server)
The PHP application runs the PHP code and generates the output as directed by the PHP code within the HTML file
The completed HTML-only file is returned by Apache to the browser via HTTP
A quick example Output after processing <html> <p>Hello there, ali </p> </html> File on server <html> <p>Hello there, <?php echo $USERNAME; ?> </p> </html> Don’t worry about the code, just remember that the PHP runs on the server and can create or modify the output displayed by the browser.
Key things to remember
Client-side browsers do NOT understand server-side languages like PHP or .NET. They understand HTML. So the end output of almost all basic server-side web applications is going to be HTML.
We’re talking about a simple back and forth application design here; the client and server take turns driving the application. Other approaches, like AJAX, are more complex.
Remember where the different technologies live Server side Software that can interact with multiple clients and can run your PHP program to allow customized ‘conversations’ with multiple clients Client side Browsers that can display HTML and can interact with different servers via HTTP This is a bit of an oversimplification (in fact, it really oversimplifies modern professional web application development practice, so don’t leave today thinking you’re suddenly an application design architect) but it’s good enough for us to go on for now.