<?
/*
Source code example for Web Database Applications
Unless otherwise stated, the source code distributed with this book can be
redistributed in source or binary form so long as an acknowledgment appears
in derived source files.
The citation should list that the code comes from Hugh E.
Williams and David Lane, "Web Database Application with PHP and MySQL"
published by O'Reilly & Associates.
This code is under copyright and cannot be included in any other book,
publication, or educational product without permission from O'Reilly &
Associates.
No warranty is attached; we cannot take responsibility for errors or fitness
for use.
*/
?>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Region Receipt</title>
</head>
<body bgcolor="white">
<?php
include 'db.inc';
include 'error.inc';
$regionId = clean($regionId, 3);
$status = clean($status, 1);
// did the insert operation succeed?
switch ($status)
{
case "T":
// Yes, insert operation succeeded.
// Show details of the new region as
// a receipt page. The new region_id
// is in the variable $regionId
$query = "SELECT * FROM region WHERE " .
"region_id = $regionId";
// Connect to the MySQL DBMS
if (!($connection = @ mysql_connect($hostName,
$username,
$password)))
die("Could not connect to database");
if (!mysql_select_db($databaseName, $connection))
showerror();
// Run the query on the DBMS
if (!($result = @ mysql_query ($query, $connection)))
showerror();
if ($row = @ mysql_fetch_array($result))
{
echo "The following region was added";
echo "\n<br>Region number: " . $row["region_id"];
echo "\n<br>Region name: " . $row["region_name"];
echo "\n<br>Region description: " . $row["description"];
// Use the script example.6-4.php to display the map GIF
echo "\n<br>Region map : ";
echo "\n<br><img src=\"example.6-4.php?region_id=" .
$regionId .
"\">";
} // if mysql_fetch_array()
// leave the switch statement
break;
case "F":
// No, insert operation failed
// Show an error message
echo "The region insert operation failed.";
echo "<br>Contact the winestore administrator.";
// leave the switch statement
break;
default:
// User did not provide a status parameter
echo "You arrived unexpectedly at this page.";
} // end of switch
?>
</body>
</html>