User's Manual
Beta Draft Updating Data 5-1
5
Updating Data
In this chapter you extend the Anyco HR application with forms that enable you to
insert, update, and delete an employee record.
Q Extending the Basic Employee Form
Q Combining Departments and Employees
Q Adding Error Recovery
Q Further Error Handling
Extending the Basic Employee Form
To enable employees records to manipulated, perform the following tasks:
1. Create the chap5 directory and copy application files from chap4:
mkdir $HOME/public_html/chap5
cp $HOME/public_html/chap4/* $HOME/public_html/chap5
cd $HOME/public_html/chap5
2. Edit anyco.php. Add form handler control logic to manage the requests for
showing, inserting, updating, and deleting employees:
<?php // File: anyco.php
require('anyco_cn.inc');
require('anyco_db.inc');
require('anyco_ui.inc');
session_start();
// Start form handler code
if (isset($_POST['insertemp'])) {
construct_insert_emp();
}
elseif (isset($_POST['saveinsertemp'])) {
insert_new_emp();
}
elseif (isset($_POST['modifyemp'])) {
construct_modify_emp();
}
elseif (isset($_POST['savemodifiedemp'])) {
modify_emp();
}
elseif (isset($_POST['deleteemp'])) {
delete_emp();
}