Welcome to Server-Side Web Languages!
This first tutorial serves as a preparation. It allows you to
check whether you have all the prerequisite knowledge you need
for this module and whether your computer account is working.
If you find that you are lacking some prerequisite knowledge,
please, use this week and next week to catch up. If there
are any problems with your Napier computer account, please,
contact C&IT as soon as possible.
Decide which programming language you want to use
You can use any programming language of your choice, but only PHP and
Perl will be supported by the lecturer.
For Perl: there are three
exercise pages on the module website
which introduce the language from the beginning. If you don't know
Perl but you would like to use it for this class, you should use today
(and probably next week) to work through the exercise pages. You don't
need to do all of the exercises given on the pages. Just try to get an
overview of how Perl works. The exercise pages are called
"Basic Operators, Logic and Control Structures, Arrays" and are on the
For PHP: there is no introduction for PHP included in this module.
If you want to use PHP but don't know how, please, use today
(and probably next week) to look at an on-line PHP introduction
of your choice. In particular, you should look at how PHP treats
strings, control structures (if, while, for) and arrays.
Also, have a look at the exercises below.
Check your computer account
Please, login to the account you want to use for server-side programming.
and check the following:
If you are using the School of Computing server, please, have a look
at the Unix/telnet help.
- Do you know how to edit, save files?
- Does the programming language you chose run on the server?
- Do you know how to access the server remotely (in case you want
to upload files from home)?
Check your programming skills
Below are a few exercises, which help you to get back into programming
in case you haven't done it for a while. If you are using Perl, you
can do these on the command-line. If you are using PHP, you need
to create a simple HTML form page for the user input (see the first
If you are having problems with any of these:
- Create a basic HTML page that contains a web form with one text field.
For Perl: you don't need any Perl for this. Simply store the page
anywhere and open it in your web browser.
For PHP: store the page on your webserver and use it for the
- Write a script that asks a user to enter an amount in dollars
which is converted into pounds by the script. Use a fictional exchange
rate of $ 1 = £ 0.5004. Your script should check whether the
user input is a positive number. If the user enters a value below 0,
the script should print an error message.
- Write a script that asks for the names and phone numbers of 5 users. Use an array
to store the user names and another array to store the phone numbers.
Then print the user names and their phone numbers twice, first, sort them
alphabetically by the user names, and second, sort them numerically by the
- Write a script that opens a locally stored file, reads the content and
then displays the first 5 lines of the file to the screen.
For Perl: have a look at the exercises for
"Basic Operators, Logic and Control Structures, Arrays" on the
For PHP: have a look at the
PHP manual. The manual contains sample scripts. If you search for
"arithmetic operators", "control structures", "array" and "file"
you will probably find everything you need.
For HTML: have a look at the links for
"HTML Intro, HTML Tags, HTML Forms" on the module website.
If you have any questions about this module, please, ask Uta Priss (the
module leader). But, please, be patient. The first tutorial can be
hectic, especially if it is on a Monday because there are often problems
with students' accounts on the very first day of the semester.