Databases Reference
In-Depth Information
APPENDIX
The Wedding Registry Code
Overview
In this appendix, we list the complete code of the wedding registry application we
developed in Chapter 15. This code is also available for download from the topic's web
site.
Example A-1 contains the code in action.php ; Example A-2 contains the code in db.php ;
Example A-3 contains the disclaimer code; Example A-4 contains the code in edit.php ;
Example A-5 contains the code in index.php ; Example A-6 contains the text in li
cense.txt ; Example A-7 contains the code in list.php ; and Example A-8 contains the
code in logout.php .
Example A-1. action.php
<?php
// action.php: Add or remove a gift from the user's shopping list
// Include database parameters and related functions
require_once("db.php");
// Check if the user is logged in
// (this also starts the session)
logincheck();
// Secure the user data
if(count($_GET))
{
// Connect to the MySQL DBMS and use the wedding database - credentials are
// in the file db.php
if(!($connection= @ mysqli_connect(
$DB_hostname, $DB_username, $DB_password, $DB_databasename)))
showerror($connection);
$gift_id = clean($_GET['gift_id'], 5);
$action = clean($_GET['action'] , 6);
// Is the action something we know about?
 
Search WWH ::




Custom Search