Lecture One - Helios Hud

Download Report

Transcript Lecture One - Helios Hud

Website Development with PHP
and MySQL
Introduction
Important information
Just in case you forgot
•
•
•
•
Steve Wade
CW3/09
[email protected]
01484 472524
Introduction to the Module
This module builds on the Web Authoring
module, extending the range of skills and
techniques developed to include server-side
scripting and database integration.
Assumed knowledge
•
•
•
•
XHTML
JavaScript
CSS
Be able to use Dreamweaver to create a static
website
Code
• Static XHTML
– Pages/data do not change without designer input
– All users see the same page
• Client side script (e.g. JavaScript)
– Data still stays the same
– Some customisation possible (e.g. colours, image changes)
– Validation of user input
• Server side script (e.g. CGI, ASP, PHP, ColdFusion)
– Pages can be ‘made’ on the fly based on variables (e.g. search input,
previous choices made by the user on their last visit, inputs from other
sites or databases)
– Page is constructed at the server end, then sent as simple html to the
client
How does it work? HTML
• First consider an HTML page:
–
–
–
–
–
You go to a webpage e.g. http://www.hud.ac.uk/
The browser goes and find the Uni. website
Once found it sends a request for the index.htm file
The server finds that page and sends it to the browser
Once received the browser looks at the HTML code, reads it and
converts it to a pretty, colourful, but static page
How does it work? CGI
• After HTML came CGI:
– HTML is one way (only receives), so something was needed to
send information back to the server. forms and CGI (Common
Gateway Interface) were created
– Forms used to get information from the user, then that
information is sent to the server where a separate program is
run to deal with it
– Great for small apps like a guestbook, but downside is every
time someone sends something to the server, a whole instance
of the CGI program is created. E.g. 5 people on site equals 5
programs running. Imagine if hundreds of people wanted to
connect at the same time?!?
How does it work? Server API’s
• CGI too slow, so Server Application
Programming Interface born. ISAPI is the
Microsoft version
• Similar to CGI, ISAPI much more efficient.
Doesn’t launch new version for every visitor
How does it work? ASP/PHP etc
• And then came ASP/PHP/ColdFusion
• Solved all the problems of CGI and ISAPI, and
they are simpler to learn and easier to use
• CGI and ISAPI written in Perl or C
• ASP/PHP/CFM simply write code in the HTML,
side by side
– As with JavaScript
How does PHP work?
• You go to a webpage e.g. www.mydomain.com/index.php
• The browser goes and finds mydomain.com
• Once found it sends a request for the index.php file
• The server finds that page and executes it, which means it looks
through the pages and runs any code in the page
• After the code has run, all php is removed from the result (so people
cannot steal it) leaving a pure HTML page
• The HTML page is sent to the browser for rendering
PHP
HTTP
HTML
HTML
Client
Web server
Why server side
•
•
•
•
•
•
•
•
•
Content sites, catalogues (imagine news.bbc.co.uk with static code?!)
Community features (forums etc)
Email (instead of mailto link, have a form on your site to be filled in)
Technical support (search your problem, solutions stored/updated in a
database)
Web delivered business applications (e.g shopping trolleys)
Directories (e.g. uni has an online phonebook)
Surveys, polls, tests (storing results and generating reports)
Personalisation
Etc etc…
Alternative Server Side Options
• ASP.NET (and the older v3.0)
– Microsoft
– Windows Server
• ColdFusion
– Macromedia
– Runs on a windows server with ColdFusion server installed
• JSP
– Java Server Pages
Installing a server on your machine
• Easier to get a package (Apache, PHP, MySQL)
– http://www.easyphp.org/
– http://www.wampserver.com/en/index.php (the
one I use)
– http://www.firepages.com.au/
Inside Uni
• http://helios.hud.ac.uk
• PHP, MySQL
• http://aspley.hud.ac.uk
• ASP.NET,
Working with Helios
There are many different ftp clients that can be used to upload files to
a web server. We will be using FileZilla.
It is installed on the machines in Canalside West and it is an Open
Source application that you can download for free and use at home.
Select start>programs>FileZilla FTP Client. FileZilla will open
Near the top of the interface enter the following settings
• Host: helios.hud.ac.uk
• Username: Your student number e.g. u01234567
• Password: Date of Birth e.g. 01jan90
Uploading a File
• Don’t specify a port
• Click “quick connect”. In the panels beneath, the
left hand panel will show the files on the local
machine. The right-hand panel will show the files
on the server.
• On the right-hand panel open the web folder
• On the left hand panel browse to a PHP file you
have created
• Select the file and press ‘enter’, a copy of the PHP
file will be transferred the helios server and
placed into the web directory
Viewing the Page
Open a web browser
Enter the following url (but change the student
number and name of the file to your own)
http://helios.hud.ac.uk/u01234567/nameOfFile.php
You should then be viewing the webpage you have
just uploaded.
Tutorial tasks
• Make sure you can access
http://helios.hud.ac.uk
• Have a go at the first PHP exercises