User's Manual

Beta Draft Getting Connected 3-1
3
Getting Connected
In this chapter you create HR application files which implement PHP functions to
connect and disconnect with the Oracle Database. You also develop a PHP function
which enables you to execute a query to validate that a database connection has been
successfully established.
It guides you through the creation and modification of PHP files that call a function to
produce the header and footer for the HR application report pages, where the footer
section of the page includes a date and time.
This chapter has the following topics:
Q Building the Departments Page
Q Connecting to the Database
Q Disconnecting from the Database
Building the Departments Page
1. To create a directory for the application files, in a command window enter the
following command:
mkdir $HOME/public_html/chap3
cd $HOME/public_html/chap3
2. To start creating the PHP application user interface framework create a file called
anyco_ui.inc that contains the two functions ui_print_header() and
ui_print_footer() with their parameters to enable web pages with consistent
header and footer sections:
<?php
function ui_print_header($title)
{
Note: For simplicity, the username and password are written into
this sample application code. For applications that will be deployed,
coding the username and password strings directly into your
application source code is not recommended. Some other technique,
such as implementing a dialog that prompts the end user for the
username and password is recommended.
See the Oracle Database Security Guide and documentation for your
development environment for details on security features and
practices.