In this concluding article, explore the scripts which add andremove timesheet entries to the system, and get a crash course instatistics by using these entries to generate useful resource allocationand usage reports.
The two halves of "view.php" correspond to two different form processors, "delete.php" and "add.php" respectively. Let's look at "add.php" first.
// add.php - add timesheet entry
// if all checks pass
// open connection to database
$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to
// create datestamp
$datestamp = $y . "-" . $m . "-" . $d;
// insert data
$query = "INSERT INTO log (pid, tid, uid, hours, date) VALUES ('$pid',
'$tid', '$SESSION_UID', '$h', '$datestamp')";
$result = mysql_db_query($database, $query, $connection) or die ("Error in
query: $query. " . mysql_error());
// close connection
// redirect back
The data received from the form in "view.php" - project, task
and hour values - is used by this script to formulate an INSERT query and insert the entry into the "log" table. The $SESSION_UID variable is used to identify which user this entry belongs to.
Once the data has been inserted, the browser is redirected back to the page it came from, using the datestamp values passed to it from "view.php".