Transcript Document

CIT 3353 -- Fall 2006
www.clt.astate.edu/jseydel/mis3353
Website Development &
Management
Getting Ready for the Server-Side
Instructor: John Seydel, Ph.D.
Student Objectives
Upon completion of this class meeting,
you should be able to:


Install PHP-related development software
Create simple web forms
First, Let’s Resolve Some SSI and
Other Issues
Your PHP repertoire, so far


Script delimiters
Variables
 Naming
 Assigning string literals

Functions
 echo()
 include()
First and second tier SSI versions
Modify footer to include link home
Questions/problems?


XML declaration
Other . . .
Now, an Intro to Forms
Forms are what made eCommerce feasible



Get info from user
Display info back to user
That is, they add interactivity !
Working with forms involves


Forms page
Forms processor, either
 Client-side or
 Server-side, or
 Both (local validation then server-side processing)
HTML Forms in Brief
At lowest level, a form consists of two elements:

Form
 <form>
 The overall container element

Input data collection control
 <input>
 A variety of types (textboxes, checkboxes, buttons, etc.)
exist and are designated by the type attribute
Example:
<form action=“formproc.php” method=“post” id=“frmDemo”>
<p>Class: <input type=“text” name=“txtClass” /> </p>
<p><input type=“submit” value=“Display Assignment” /> </p>
</form>
Several other data collection controls exist
Getting Started with Forms
Main element is <form>

Attributes:
 id (for object references in scripts)
 action (where the form processor is)
 method (usually post but sometimes get)

Should be only one per page (for our purposes)
All controls must be within <form> ... </form>

Form controls





input (many types)
button
select
textarea
Forms also typically contain standard inline (e.g.,
<em>) and block (e.g., <table> ) elements
Basic Forms Example
Suzy Student Guestbook
Look at the tags


Elements
Attributes
Note the action attribute



This is the form processor
Use any URL, including email
However, email submission is very undependable
Our PHP Environment (LAMP)
The components

Operating system
 Linux (production machine)  LAMP
 Windows (development machine)  WAMP



MySQL: the DBMS and server
Apache: the web server
PHP: the scripting engine
For best results, install in that order
Before downloading



Make sure you have administrator permissions
Stop IIS if it’s running
Create a desktop folder Downloads
The Installation Process: MySQL
Generally follows procedure given in Meloni textbook
Download mysql-4.0.24-win.zip from course
Handouts page (or from MySQL.com) into Downloads
directory
Uncompress into a default temporary directory and
then open that directory
Double-click on SETUP.EXE and accept all defaults as
the installation wizard runs
Test the installation




Run c:\mysql\bin\winmysqladmin.exe
Provide a username and password you’ll remember (generally,
these won’t be used again, ever)
Note the stoplight now on taskbar at bottom right
MySQL’s database server now starts upon bootup
For now, go no further (i.e., not beyond p. 8)
The Installation Process: Apache
Again, ensure that IIS is stopped
Also follows procedure given in Meloni textbook but with
some variations; assumes you’ll be installing PHP right away
Download apache_2.0.54-win32-x86-no_ssl.msi from
course Handouts page (or from Apache.org) into
Downloads directory
Double-click on apache_2.0.54-win32-x86-no_ssl.msi


Accept defaults as the installation wizard runs
Don’t worry for now about Server Information panel
Verify the installation


Note the feather icon near the right end of the taskbar
Point browser to http://127.0.0.1 (output displayed on p. 29 should
appear)
Modify the configuration . . .
Modifications to Apache
Edit the configuration file:
c:\Program Files\Apache Group\Apache2\conf\httpd.conf
Specify server settings:


Find ServerAdmin statement and set the argument to your
email address
Find ServerName statement and set the argument to your
IP address or to 127.0.0.1
Two more changes:

Add to the end of the LoadModule section
LoadModule php5_module c:/php/php5apache2.dll

Add to the end of the AddType section
AddType application/x-httpd-php .phtml .php
Do not restart Apache until after installing PHP
The Installation Process: PHP
Varies somewhat from procedure given in
Meloni textbook
Download php-5.0.4-Win32.zip from course
Handouts page (or from PHP.net) into
Downloads directory
Uncompress into a permanent directory
(c:\php) and then open that directory
Configure PHP (see next slide)
Restart Apache


Click on taskbar icon (feather)
Then Apache2 | Restart
Configuring PHP
Make changes to files



Copy c:\php\php.ini-dist to c:\WINDOWS
Rename c:\WINDOWS\php.ini-dist to c:\WINDOWS\php.ini
Edit c:\WINDOWS\php.ini
 Open in NotePad
 Find and uncomment (remove “;”) extension=php_mysql.dll
 Find and set error reporting configuration


error_reporting = E_ALL & ~E_NOTICE
display_errors = On
 Setup for email (example)


SMTP = smail.astate.edu
sendmail_from = [email protected]
 Save and close the file



Copy c:\php\php5ts.dll to c:\WINDOWS\system
Copy c:\php\ext\php_mysql.dll to c:\WINDOWS\system
Copy c:\mysql\bin\libmysql.dll to c:\WINDOWS\system
Restart Apache
If Modifications are Needed
Apache:


Modify the httpd.conf file and then restart
Located in C:\Program Files\Apache
Group\Apache2\conf
PHP:


Modify the php.ini file and then restart Apache
Located in C:\WINDOWS
MySQL: we’ll address this later
Summary of Today’s Objectives
Create simple web forms
Install PHP-related development software
Appendix
Browser/Server Interaction
Server-Side Include Exercise
Locally, make 4 copies of index.html




index.php
header1.shtml
header2.shtml
styles1.shtml
Edit these files, save them, and post them to SuSE1




header1.shtml: remove all before <h1> and after </h1>
footer1.shtml: remove all before <hr /> and after last </p>
styles1.shtml: remove all before <style> and after </style>
index.php (first remove XML directive, for now)






Remove all
Insert: <?
Remove all
Insert: <?
Remove all
Insert: <?
between <style> and </style> inclusive
include("styles1.shtml"); ?>
between <h1> and </h1> inclusive
include("header1.shtml"); ?>
between <hr /> and last </p> inclusive
include("footer1.shtml"); ?>