FIT2094-FIT3171 Databases
Session 12 Tutorial Activities DB Connectivity, Web Technology
FIT Database Teaching Team
Complete session 12 activities in week 6 listed below
12.1 DB Connectivity using PHP
12.2 Frameworks and Security Consideration 12.3 Web Modification Exercise
12.4 SETU and Assignment 2
FIT2094-FIT3171 2021 Summer B
FIT2094-FIT3171 Databases
Author: FIT Database Teaching Team
License: Copyright Monash University, unless otherwise stated. All Rights Reserved.
COPYRIGHT WARNING
Warning
This material is protected by copyright. For use within Monash University only. NOT FOR RESALE. Do not remove this notice.
Page 1 of 8
12.1 DB Connectivity using PHP
Now that you are familiar with designing, creating and managing tables we will look at the manner in which such data can be accessed. To date you have been using SQL Developer, clearly, in practice, your users will not have access to/use this item of software. Access to your created tables by normal users will be via an application or web front end.
For this tutorial, we are going to develop a basic web front end. To do this we are going to make use of PHP (recursive acronym for PHP: Hypertext Preprocessor) one of the most widely used programming languages, especially for web development. Please note that this is a very basic introduction so that you become aware of the possibilities. PHP is a full OO language with a wide range of features. Development under PHP is commercially carried out via PHP Frameworks.
PHP enables the mixing of PHP code (marked between) and standard HTML code within a single file. When accessed via the web server the PHP code is handled via the PHP processor on the web server and replaced with appropriate output. For this unit we are not expecting you to become PHP experts, this is simply an exercise to increase your awareness of how a database can be accessed via the web. If you wish to delve further into PHP immediately there are a large number of good tutorials available on the web. A good starting point is https://www.w3schools.com/php/
The steps in using PHP to access table data are:
connect to the database
define a SQL query string
parse the SQL query against the database
execute the statement
fetch and display the data, and finally
free the resources being used and close the connection.
You have been given an account on the server http://fit-db.infotech.monash.edu/ this server can be accessed in two ways:
via the web by using a URL of the form: http://fit-db.infotech.monash.edu/~yourauthcateusername/ or
via SFTP for transferring files to the server.
Note that this server can only be accessed within the Monash network or via Monash VPN.
To create a connection to the server open an SFTP client such as FileZilla. With FileZilla select Open the Site Manager:
and pick SFTP as access type (Protocol) and enter the server name (Host):
Page 2 of 8
Before selecting Connect, click on the NewSite under My Sites on the left and give your connection an appropriate name (here DB Infotech). Also please ensure you use the Logon Type Ask for password so that FileZilla will prompt you for your password at each connection and not remember it. Use your Monash username and password and click Connect.
After clicking on Connect, your connection will open and FileZilla will show your local files on the left and the server (remote) files on the right. Navigate using the right until you are located in your public_html folder. Documents placed in this folder will be published via the web server running on http://fit-db.infotech.monash.edu/.
To create the PHP files we will need you should make use of a text editor such as Atom or Notepad++ (MS Windows ) or Brackets
The first PHP script we wish to create is a form which will ask you to input your Oracle connection details and call the page which will display the data from the database. The file should be called login_uni_student.php and have the form:
Reviews
There are no reviews yet.