diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/9781484238424.jpg b/9781484238424.jpg new file mode 100644 index 0000000..c4ec1ee Binary files /dev/null and b/9781484238424.jpg differ diff --git a/Ch01/change-password.php b/Ch01/change-password.php new file mode 100644 index 0000000..1719254 --- /dev/null +++ b/Ch01/change-password.php @@ -0,0 +1,101 @@ + + + + Template for an interactive web page + + + + + + + +
+ +
+ +
+ +
+ + + + +
+

Change Password

+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + Between 8 and 12 characters. +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ +'; + } + else + { + echo ''; + echo '
'; + echo ' +
+ + diff --git a/Ch01/footer.php b/Ch01/footer.php new file mode 100644 index 0000000..4ccb7e8 --- /dev/null +++ b/Ch01/footer.php @@ -0,0 +1,5 @@ +

Copyright © Adrian West & Steve Prettyman 2018 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

\ No newline at end of file diff --git a/Ch01/header-for-template.php b/Ch01/header-for-template.php new file mode 100644 index 0000000..0a925b3 --- /dev/null +++ b/Ch01/header-for-template.php @@ -0,0 +1,7 @@ +
+Logo +
+
+

This is the header

+
+ \ No newline at end of file diff --git a/Ch01/header.php b/Ch01/header.php new file mode 100644 index 0000000..167eeb2 --- /dev/null +++ b/Ch01/header.php @@ -0,0 +1,13 @@ +
+Logo +
+
+

Header Goes Here

+
+ \ No newline at end of file diff --git a/Ch01/index.php b/Ch01/index.php new file mode 100644 index 0000000..e577826 --- /dev/null +++ b/Ch01/index.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
+ +
+ +
+ +
+ + + +
+

This is the Home Page

+

The home page content. The home page content. The home page content. The home page content.
+ The home page content. The home page content. The home page content. The home page content.
+ The home page content. The home page content.
+ The home page content. The home page content. The home page content.

+
+ + +
+ + +
+ + diff --git a/Ch01/info-col.php b/Ch01/info-col.php new file mode 100644 index 0000000..0e530aa --- /dev/null +++ b/Ch01/info-col.php @@ -0,0 +1,4 @@ +
+

This is the information column

+

Web design by
A W West and
Steve Prettyman

+
\ No newline at end of file diff --git a/Ch01/logo.jpg b/Ch01/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch01/logo.jpg differ diff --git a/Ch01/menu.php b/Ch01/menu.php new file mode 100644 index 0000000..11f463b --- /dev/null +++ b/Ch01/menu.php @@ -0,0 +1,4 @@ + +
  • Register
  • +
  • View Users
  • +
  • New Password
  • diff --git a/Ch01/mysqli_connect.php b/Ch01/mysqli_connect.php new file mode 100644 index 0000000..8f8d588 --- /dev/null +++ b/Ch01/mysqli_connect.php @@ -0,0 +1,13 @@ + + + + + + + + + + + + + +
    + + +
    + + +
    +

    Project 1 incomplete

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +
    + + + + + \ No newline at end of file diff --git a/Ch01/nav.php b/Ch01/nav.php new file mode 100644 index 0000000..f0932a6 --- /dev/null +++ b/Ch01/nav.php @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/Ch01/nav.txt b/Ch01/nav.txt new file mode 100644 index 0000000..5be2e9f --- /dev/null +++ b/Ch01/nav.txt @@ -0,0 +1,53 @@ + + + + + + + + + + + + +
    + + +
    + + +
    +

    Project 1 incomplete

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +
    + + + + + \ No newline at end of file diff --git a/Ch01/password-thanks.php b/Ch01/password-thanks.php new file mode 100644 index 0000000..3f516ea --- /dev/null +++ b/Ch01/password-thanks.php @@ -0,0 +1,45 @@ + + + + Password Change Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for changing your password

    +On the Home Page, you will now be able to login with your new password. +
    + + +
    + + +
    + + diff --git a/Ch01/process-change-password.php b/Ch01/process-change-password.php new file mode 100644 index 0000000..f40f461 --- /dev/null +++ b/Ch01/process-change-password.php @@ -0,0 +1,110 @@ + + You could not change password due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + // include footer then close program to stop execution + echo ''; + exit(); + } + } else { // Invalid email address/password combination. + $errorstring = 'Error!
    '; + $errorstring .= 'The email address and/or password do not match those on file.'; + $errorstring .= " Please try again."; + echo "

    $errorstring

    "; +} } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. + //header ("location: register-page.php"); + $errorstring = "Error! The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> + + + + + + + diff --git a/Ch01/process-register-page.php b/Ch01/process-register-page.php new file mode 100644 index 0000000..1108103 --- /dev/null +++ b/Ch01/process-register-page.php @@ -0,0 +1,85 @@ + +"; + $errorstring .= "System Error
    You could not be registered due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + mysqli_close($dbcon); // Close the database connection. + // include footer then close program to stop execution + echo ''; + exit(); + } + } + catch(Exception $e) // We finally handle any problems here #12 + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. #13 + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> \ No newline at end of file diff --git a/Ch01/register-page.php b/Ch01/register-page.php new file mode 100644 index 0000000..8c9002a --- /dev/null +++ b/Ch01/register-page.php @@ -0,0 +1,109 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch01/register-thanks.php b/Ch01/register-thanks.php new file mode 100644 index 0000000..4a01df2 --- /dev/null +++ b/Ch01/register-thanks.php @@ -0,0 +1,45 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +On the Home Page, you will now be able to login and add new quotes to the message board. +
    + + +
    + + +
    + + diff --git a/Ch01/register-view-users.php b/Ch01/register-view-users.php new file mode 100644 index 0000000..55fcc35 --- /dev/null +++ b/Ch01/register-view-users.php @@ -0,0 +1,86 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch01/simpledb.sql b/Ch01/simpledb.sql new file mode 100644 index 0000000..6e6c6a5 --- /dev/null +++ b/Ch01/simpledb.sql @@ -0,0 +1,74 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 06:37 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `simpledb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(60) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `first_name`, `last_name`, `email`, `password`, `registration_date`) VALUES +(1, 'Steve', 'Johnson', 'sjohnson@sjohnson.com', '$2y$10$lEmRKPYfu/Nb6ECtbmp7YOuIZeZDYuCnZKRmEBnQ6nRHDKJHdEgMK', '2018-04-26 15:11:58'), +(2, 'Mike', 'Rosolt', 'mrosolf@someplace.com', '$2y$10$9lXam45bwNHu4/zbu5FdXuW243F1R0GkQBDJr/juvV8wYr6lMZbau', '2018-04-28 15:15:32'), +(3, 'Tweedle', 'Dee-Deest', 'tdeedeest@themail.com', '$2y$10$.ewnSKbbeP6lSI4UF0BasOTnDyLzBH8mwcDM3wEM1hzoJAXYz2doK', '2018-04-28 15:17:29'), +(4, 'Annie', 'Versary', 'aversary@outcook.com', '$2y$10$5yz6IiFq/uZR4VdacjVRbOWTIA5tZCSLZ975mGZCoas3UHMMojN46', '2018-04-28 15:18:17'), +(5, 'Charley', 'Farnsbarns', 'cfransnarns@outcook.com', '$2y$10$WFX630.YbR5WQcYNBnMMueIbjIbo5.C6aDkUKVUfXBC1oNrqasmWa', '2018-04-28 15:19:50'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch01/template.php b/Ch01/template.php new file mode 100644 index 0000000..efdbacb --- /dev/null +++ b/Ch01/template.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + + +
    + + diff --git a/Ch01/verify.js b/Ch01/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch01/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch02/simpledb/change-password.php b/Ch02/simpledb/change-password.php new file mode 100644 index 0000000..1719254 --- /dev/null +++ b/Ch02/simpledb/change-password.php @@ -0,0 +1,101 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo ' +
    + + diff --git a/Ch02/simpledb/footer.php b/Ch02/simpledb/footer.php new file mode 100644 index 0000000..4ccb7e8 --- /dev/null +++ b/Ch02/simpledb/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2018 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch02/simpledb/header-for-template.php b/Ch02/simpledb/header-for-template.php new file mode 100644 index 0000000..0a925b3 --- /dev/null +++ b/Ch02/simpledb/header-for-template.php @@ -0,0 +1,7 @@ +
    +Logo +
    +
    +

    This is the header

    +
    + \ No newline at end of file diff --git a/Ch02/simpledb/header.php b/Ch02/simpledb/header.php new file mode 100644 index 0000000..167eeb2 --- /dev/null +++ b/Ch02/simpledb/header.php @@ -0,0 +1,13 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch02/simpledb/index.php b/Ch02/simpledb/index.php new file mode 100644 index 0000000..e577826 --- /dev/null +++ b/Ch02/simpledb/index.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + + +
    + + diff --git a/Ch02/simpledb/info-col.php b/Ch02/simpledb/info-col.php new file mode 100644 index 0000000..0e530aa --- /dev/null +++ b/Ch02/simpledb/info-col.php @@ -0,0 +1,4 @@ +
    +

    This is the information column

    +

    Web design by
    A W West and
    Steve Prettyman

    +
    \ No newline at end of file diff --git a/Ch02/simpledb/logo.jpg b/Ch02/simpledb/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch02/simpledb/logo.jpg differ diff --git a/Ch02/simpledb/menu.php b/Ch02/simpledb/menu.php new file mode 100644 index 0000000..11f463b --- /dev/null +++ b/Ch02/simpledb/menu.php @@ -0,0 +1,4 @@ + +
  • Register
  • +
  • View Users
  • +
  • New Password
  • diff --git a/Ch02/simpledb/mysqli_connect.php b/Ch02/simpledb/mysqli_connect.php new file mode 100644 index 0000000..8f8d588 --- /dev/null +++ b/Ch02/simpledb/mysqli_connect.php @@ -0,0 +1,13 @@ + + + + + + + + + + + + + +
    + + +
    + + +
    +

    Project 1 incomplete

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +
    + + + + + \ No newline at end of file diff --git a/Ch02/simpledb/nav.php b/Ch02/simpledb/nav.php new file mode 100644 index 0000000..f0932a6 --- /dev/null +++ b/Ch02/simpledb/nav.php @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/Ch02/simpledb/nav.txt b/Ch02/simpledb/nav.txt new file mode 100644 index 0000000..5be2e9f --- /dev/null +++ b/Ch02/simpledb/nav.txt @@ -0,0 +1,53 @@ + + + + + + + + + + + + +
    + + +
    + + +
    +

    Project 1 incomplete

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +

    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    +
    + + + + + \ No newline at end of file diff --git a/Ch02/simpledb/password-thanks.php b/Ch02/simpledb/password-thanks.php new file mode 100644 index 0000000..3f516ea --- /dev/null +++ b/Ch02/simpledb/password-thanks.php @@ -0,0 +1,45 @@ + + + + Password Change Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for changing your password

    +On the Home Page, you will now be able to login with your new password. +
    + + +
    + + +
    + + diff --git a/Ch02/simpledb/process-change-password.php b/Ch02/simpledb/process-change-password.php new file mode 100644 index 0000000..f40f461 --- /dev/null +++ b/Ch02/simpledb/process-change-password.php @@ -0,0 +1,110 @@ + + You could not change password due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + // include footer then close program to stop execution + echo ''; + exit(); + } + } else { // Invalid email address/password combination. + $errorstring = 'Error!
    '; + $errorstring .= 'The email address and/or password do not match those on file.'; + $errorstring .= " Please try again."; + echo "

    $errorstring

    "; +} } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. + //header ("location: register-page.php"); + $errorstring = "Error! The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> + + + + + + + diff --git a/Ch02/simpledb/process-register-page.php b/Ch02/simpledb/process-register-page.php new file mode 100644 index 0000000..1108103 --- /dev/null +++ b/Ch02/simpledb/process-register-page.php @@ -0,0 +1,85 @@ + +"; + $errorstring .= "System Error
    You could not be registered due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + mysqli_close($dbcon); // Close the database connection. + // include footer then close program to stop execution + echo ''; + exit(); + } + } + catch(Exception $e) // We finally handle any problems here #12 + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. #13 + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> \ No newline at end of file diff --git a/Ch02/simpledb/register-page.php b/Ch02/simpledb/register-page.php new file mode 100644 index 0000000..8c9002a --- /dev/null +++ b/Ch02/simpledb/register-page.php @@ -0,0 +1,109 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch02/simpledb/register-thanks.php b/Ch02/simpledb/register-thanks.php new file mode 100644 index 0000000..4a01df2 --- /dev/null +++ b/Ch02/simpledb/register-thanks.php @@ -0,0 +1,45 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +On the Home Page, you will now be able to login and add new quotes to the message board. +
    + + +
    + + +
    + + diff --git a/Ch02/simpledb/register-view-users.php b/Ch02/simpledb/register-view-users.php new file mode 100644 index 0000000..55fcc35 --- /dev/null +++ b/Ch02/simpledb/register-view-users.php @@ -0,0 +1,86 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch02/simpledb/simpledb.sql b/Ch02/simpledb/simpledb.sql new file mode 100644 index 0000000..6e6c6a5 --- /dev/null +++ b/Ch02/simpledb/simpledb.sql @@ -0,0 +1,74 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 06:37 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `simpledb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(60) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `first_name`, `last_name`, `email`, `password`, `registration_date`) VALUES +(1, 'Steve', 'Johnson', 'sjohnson@sjohnson.com', '$2y$10$lEmRKPYfu/Nb6ECtbmp7YOuIZeZDYuCnZKRmEBnQ6nRHDKJHdEgMK', '2018-04-26 15:11:58'), +(2, 'Mike', 'Rosolt', 'mrosolf@someplace.com', '$2y$10$9lXam45bwNHu4/zbu5FdXuW243F1R0GkQBDJr/juvV8wYr6lMZbau', '2018-04-28 15:15:32'), +(3, 'Tweedle', 'Dee-Deest', 'tdeedeest@themail.com', '$2y$10$.ewnSKbbeP6lSI4UF0BasOTnDyLzBH8mwcDM3wEM1hzoJAXYz2doK', '2018-04-28 15:17:29'), +(4, 'Annie', 'Versary', 'aversary@outcook.com', '$2y$10$5yz6IiFq/uZR4VdacjVRbOWTIA5tZCSLZ975mGZCoas3UHMMojN46', '2018-04-28 15:18:17'), +(5, 'Charley', 'Farnsbarns', 'cfransnarns@outcook.com', '$2y$10$WFX630.YbR5WQcYNBnMMueIbjIbo5.C6aDkUKVUfXBC1oNrqasmWa', '2018-04-28 15:19:50'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch02/simpledb/template.php b/Ch02/simpledb/template.php new file mode 100644 index 0000000..efdbacb --- /dev/null +++ b/Ch02/simpledb/template.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + + +
    + + diff --git a/Ch02/simpledb/verify.js b/Ch02/simpledb/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch02/simpledb/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch03/login/admin-page.php b/Ch03/login/admin-page.php new file mode 100644 index 0000000..e4ccc1d --- /dev/null +++ b/Ch03/login/admin-page.php @@ -0,0 +1,57 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Administration Page

    +

    You have permission to:

    +

    ■Edit and Delete a record

    +

    ■Use the View Members button to page through all the members

    +

    ■Use the Search button to locate a particular member

    +

    ■Use the New Password button to change your password. +

    +
    + + +
    + + +
    + + diff --git a/Ch03/login/admin-view-users.php b/Ch03/login/admin-view-users.php new file mode 100644 index 0000000..0da160c --- /dev/null +++ b/Ch03/login/admin-view-users.php @@ -0,0 +1,93 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch03/login/admin_view_users.php b/Ch03/login/admin_view_users.php new file mode 100644 index 0000000..0da160c --- /dev/null +++ b/Ch03/login/admin_view_users.php @@ -0,0 +1,93 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch03/login/change-password.php b/Ch03/login/change-password.php new file mode 100644 index 0000000..0e6f68c --- /dev/null +++ b/Ch03/login/change-password.php @@ -0,0 +1,101 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo ' +
    + + diff --git a/Ch03/login/footer.php b/Ch03/login/footer.php new file mode 100644 index 0000000..4ccb7e8 --- /dev/null +++ b/Ch03/login/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2018 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch03/login/header-admin.php b/Ch03/login/header-admin.php new file mode 100644 index 0000000..2a2ab7d --- /dev/null +++ b/Ch03/login/header-admin.php @@ -0,0 +1,18 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + + + + diff --git a/Ch03/login/header-members.php b/Ch03/login/header-members.php new file mode 100644 index 0000000..3bf6406 --- /dev/null +++ b/Ch03/login/header-members.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch03/login/header-thanks.php b/Ch03/login/header-thanks.php new file mode 100644 index 0000000..b3587a4 --- /dev/null +++ b/Ch03/login/header-thanks.php @@ -0,0 +1,10 @@ + + diff --git a/Ch03/login/header.php b/Ch03/login/header.php new file mode 100644 index 0000000..92bb26a --- /dev/null +++ b/Ch03/login/header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch03/login/images/polo.png b/Ch03/login/images/polo.png new file mode 100644 index 0000000..bca2bd2 Binary files /dev/null and b/Ch03/login/images/polo.png differ diff --git a/Ch03/login/index.php b/Ch03/login/index.php new file mode 100644 index 0000000..e577826 --- /dev/null +++ b/Ch03/login/index.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + + +
    + + diff --git a/Ch03/login/info-col.php b/Ch03/login/info-col.php new file mode 100644 index 0000000..1c1ae88 --- /dev/null +++ b/Ch03/login/info-col.php @@ -0,0 +1,3 @@ +

    This is the information column

    +

    Information area

    + diff --git a/Ch03/login/login-header.php b/Ch03/login/login-header.php new file mode 100644 index 0000000..9602ddc --- /dev/null +++ b/Ch03/login/login-header.php @@ -0,0 +1,13 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch03/login/login.php b/Ch03/login/login.php new file mode 100644 index 0000000..491873e --- /dev/null +++ b/Ch03/login/login.php @@ -0,0 +1,83 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Login

    +
    +
    + +
    + +
    +
    +
    + +
    + +  Between 8 and 12 characters.

    +
    +
    +
    +
    + +
    +
    +
    +
    + + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch03/login/login_page.inc.php b/Ch03/login/login_page.inc.php new file mode 100644 index 0000000..9ee78ca --- /dev/null +++ b/Ch03/login/login_page.inc.php @@ -0,0 +1,14 @@ +

    Login

    +
    +

    +

    + +

    + + Between 8 and 12 characters.

    +

    +

    diff --git a/Ch03/login/logindb.sql b/Ch03/login/logindb.sql new file mode 100644 index 0000000..c3466dc --- /dev/null +++ b/Ch03/login/logindb.sql @@ -0,0 +1,78 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: May 17, 2018 at 11:58 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `logindb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(60) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `user_level` tinyint(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `user_level`) VALUES +(20, 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$VWtLxXTE1ohO1pQJ87tnGeBB1MNfkQ3V87/HIGdanmKhqflRIQEH2', '2018-05-17 17:33:49', 0), +(21, 'Olive', 'Branch', 'obranch@myisp.com.uk', '$2y$10$aAdvrMiVcEFqRn9ISLoy6uEwS.FesiTQZ.IdsHGc/xSi2x.wkuaZ2', '2018-05-17 17:35:21', 0), +(22, 'Frank', 'Insence', 'finsence@myisp.net', '$2y$10$0WbSaI3w.9KjkE28L7ZeN.jEPKvsPLIwRg01M6XkRtWvZkOWaT3R6', '2018-05-17 17:36:46', 0), +(23, 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$HpUHsg0yoIy08d4./p/tM.ZLOnZ3RLGTb7YjqMEuzwb2yBpEguB9O', '2018-05-17 17:37:47', 0), +(24, 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$Gh0nTJPXxUkZAKCkOeVC8O8jv3rJ6ZLXrEJ8szvgqDgBxb1F8uVSa', '2018-05-17 17:54:39', 0), +(25, 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$cASUiiV3w3cKWoaxH0tfmeV7IwXy2fUNJT6lQIdBbUZePmtPY/Wo2', '2018-05-17 17:55:38', 0), +(26, 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$pp/Gv2tvaTUlfPKVRb/tSu/25N7mhvj7h2ybRANEvS.I2xg/99wM6', '2018-05-17 17:57:11', 0), +(27, 'Jack', 'Smith', 'jsmith@outcook.com', '$2y$10$GXDlk.GkgdWmPRTUDCb.F.kqD.8dwkH93s0p/g1f0fnK27Z849Ry2', '2018-05-17 17:58:14', 1); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch03/login/logo.jpg b/Ch03/login/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch03/login/logo.jpg differ diff --git a/Ch03/login/logout.php b/Ch03/login/logout.php new file mode 100644 index 0000000..d8abea1 --- /dev/null +++ b/Ch03/login/logout.php @@ -0,0 +1,18 @@ + +Logo + +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch03/login/members-page.php b/Ch03/login/members-page.php new file mode 100644 index 0000000..e6252d1 --- /dev/null +++ b/Ch03/login/members-page.php @@ -0,0 +1,61 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Member's Page

    +

    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +

    +

    Special offers to members only.

    +

    T-Shirts 10.00

    +Polo Shirt +
    +
    + + +
    + + +
    + + + diff --git a/Ch03/login/mysqli_connect.php b/Ch03/login/mysqli_connect.php new file mode 100644 index 0000000..13b2614 --- /dev/null +++ b/Ch03/login/mysqli_connect.php @@ -0,0 +1,11 @@ + + Home + + + + + \ No newline at end of file diff --git a/Ch03/login/password-header.php b/Ch03/login/password-header.php new file mode 100644 index 0000000..e6fc6c8 --- /dev/null +++ b/Ch03/login/password-header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch03/login/process-change-password.php b/Ch03/login/process-change-password.php new file mode 100644 index 0000000..f40f461 --- /dev/null +++ b/Ch03/login/process-change-password.php @@ -0,0 +1,110 @@ + + You could not change password due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + // include footer then close program to stop execution + echo ''; + exit(); + } + } else { // Invalid email address/password combination. + $errorstring = 'Error!
    '; + $errorstring .= 'The email address and/or password do not match those on file.'; + $errorstring .= " Please try again."; + echo "

    $errorstring

    "; +} } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. + //header ("location: register-page.php"); + $errorstring = "Error! The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> + + + + + + + diff --git a/Ch03/login/process-login.php b/Ch03/login/process-login.php new file mode 100644 index 0000000..e014b3f --- /dev/null +++ b/Ch03/login/process-login.php @@ -0,0 +1,83 @@ + The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (!empty($errors)) IF. +mysqli_stmt_free_result($q); +mysqli_stmt_close($q); +} + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +} // no else to allow user to enter values +?> \ No newline at end of file diff --git a/Ch03/login/process-register-page.php b/Ch03/login/process-register-page.php new file mode 100644 index 0000000..777059b --- /dev/null +++ b/Ch03/login/process-register-page.php @@ -0,0 +1,85 @@ +"; + $errorstring .= "System Error
    You could not be registered due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + mysqli_close($dbcon); // Close the database connection. + // include footer then close program to stop execution + echo ''; + exit(); + } + } else { // Report the errors. + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. + } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> \ No newline at end of file diff --git a/Ch03/login/register-header.php b/Ch03/login/register-header.php new file mode 100644 index 0000000..44f145a --- /dev/null +++ b/Ch03/login/register-header.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch03/login/register-page.php b/Ch03/login/register-page.php new file mode 100644 index 0000000..3d419c7 --- /dev/null +++ b/Ch03/login/register-page.php @@ -0,0 +1,108 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch03/login/register-password.php b/Ch03/login/register-password.php new file mode 100644 index 0000000..0e6f68c --- /dev/null +++ b/Ch03/login/register-password.php @@ -0,0 +1,101 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo ' +
    + + diff --git a/Ch03/login/register-thanks.php b/Ch03/login/register-thanks.php new file mode 100644 index 0000000..fb520c1 --- /dev/null +++ b/Ch03/login/register-thanks.php @@ -0,0 +1,45 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +On the Home Page, you will now be able to login and add new quotes to the message board. +
    + + +
    + + +
    + + diff --git a/Ch03/login/register-view-users.php b/Ch03/login/register-view-users.php new file mode 100644 index 0000000..2859874 --- /dev/null +++ b/Ch03/login/register-view-users.php @@ -0,0 +1,93 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch03/login/thanks-header.php b/Ch03/login/thanks-header.php new file mode 100644 index 0000000..7a0b906 --- /dev/null +++ b/Ch03/login/thanks-header.php @@ -0,0 +1,11 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch03/login/verify.js b/Ch03/login/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch03/login/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch04/admintable/admintable/admin-page.php b/Ch04/admintable/admintable/admin-page.php new file mode 100644 index 0000000..e4ccc1d --- /dev/null +++ b/Ch04/admintable/admintable/admin-page.php @@ -0,0 +1,57 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Administration Page

    +

    You have permission to:

    +

    ■Edit and Delete a record

    +

    ■Use the View Members button to page through all the members

    +

    ■Use the Search button to locate a particular member

    +

    ■Use the New Password button to change your password. +

    +
    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/admin-view-users.php b/Ch04/admintable/admintable/admin-view-users.php new file mode 100644 index 0000000..949a47f --- /dev/null +++ b/Ch04/admintable/admintable/admin-view-users.php @@ -0,0 +1,117 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + + +Edit +Delete +Last Name +First Name +Email +Date Registered +'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to #5 + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + Edit + Delete + ' . $last_name . ' + ' . $first_name . ' + ' . $email . ' + ' . $registration_date . ' + '; + } + echo ''; // Close the table. + // #7 + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/admin_view_users.php b/Ch04/admintable/admintable/admin_view_users.php new file mode 100644 index 0000000..912a239 --- /dev/null +++ b/Ch04/admintable/admintable/admin_view_users.php @@ -0,0 +1,55 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +

    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/admintable.sql b/Ch04/admintable/admintable/admintable.sql new file mode 100644 index 0000000..40abe2d --- /dev/null +++ b/Ch04/admintable/admintable/admintable.sql @@ -0,0 +1,120 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 06:53 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `admintable` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prices` +-- + +CREATE TABLE `prices` ( + `oneyeargb` decimal(6,0) UNSIGNED NOT NULL, + `oneyearus` decimal(6,0) UNSIGNED NOT NULL, + `fiveyeargb` decimal(6,0) NOT NULL, + `fiveyearus` decimal(6,0) NOT NULL, + `militarygb` decimal(6,0) NOT NULL, + `militaryus` decimal(6,0) NOT NULL, + `u21gb` decimal(6,0) NOT NULL, + `u21us` decimal(6,0) NOT NULL, + `minpricegb` decimal(6,0) NOT NULL, + `minpriceus` decimal(6,0) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dumping data for table `prices` +-- + +INSERT INTO `prices` (`oneyeargb`, `oneyearus`, `fiveyeargb`, `fiveyearus`, `militarygb`, `militaryus`, `u21gb`, `u21us`, `minpricegb`, `minpriceus`) VALUES +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'), +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `user_level` tinyint(1) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `user_level`) VALUES +(1, 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$fB/cbTyl.l0V3/iOpxdTHelBwoXrtoI0R8rksyMyLz5yZByIZvNgi', '2017-11-28 10:34:46', 0), +(3, 'Jack', 'Smith', 'jsmith@outcook.com', '$2y$10$pf7khel0dwUCjX1211Pgpue73otgQ94gfviGe5WyH6IUJHcIlww3i', '2017-11-28 10:42:11', 1), +(4, 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$02usUgNBg9ITWL4b43Qwq.BbCncs4oobO2NVJUjgnTDlaICXFw/TO', '2017-11-28 10:44:12', 0), +(5, 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$MSzF.LyLKAjcBK29iAyGtu79kKljLgjow4geSX.MubrC9pzLPN566', '2017-11-28 10:45:05', 0), +(6, 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$sm8haAl94e.LzgD9hhbd1.GbIhFZ3bPNWiHwHfNCQAUlA1n421see', '2017-11-28 10:45:52', 0), +(34, 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$IO8Gcy7MWk9TzfV2HjVg4Oao46UfusHN.fCnfrl8eIh4EyeDMYl4u', '2018-05-31 15:14:53', 0), +(35, 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$iro7lP10KjUV76voOlJfGecUU9BmDieBbntc0hRzA7BY3ajy0LUWK', '2018-05-31 15:18:02', 0), +(36, 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$F6Ft/m92sn6QuPyPn4/hNeGJlqmN/6lDtUCHNL/o5cH7KeAZkoRuG', '2018-05-31 15:19:13', 0), +(37, 'Percy', 'Veer', 'pveer@myisp.com', '$2y$10$uAAkr6vvQOEEl3yl4aoy6.p5.vR5C8z8xUFr1DAH6bdM6b2.cx6JS', '2018-05-31 17:06:02', 0), +(38, 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$2KpmjaxVIXrobj.eCfyHHu97dNKy5goAlVnFkuh233.JLz3DB3FLW', '2018-05-31 17:06:57', 0), +(39, 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$Q5g7vfrMpcgufwnxdCvoe.yTjdo7MfzQy5OGuIHDpNdqmYWj6PL7i', '2018-05-31 17:07:49', 0), +(40, 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$IT8LaiC8USftBTU5Ni/zauaeYLpwDlDSmtuV.Spwrtl5jkmg.kBgK', '2018-05-31 17:08:39', 0), +(41, 'Dee', 'Jected', 'djected@myisp.ork.uk', '$2y$10$OFuKWogf2M5YyPW2cuCs5.2IPfDdU5K65gUlww0oOuRHTWlcUstgm', '2018-05-31 17:09:30', 0), +(42, 'Lynn', 'Steed', 'lseed@myisp.com', '$2y$10$Umfyip63mNyRks4Dzd5or.ul/agTTWtbaiDrXLjtudz7kIH/MfE4C', '2018-05-31 17:10:21', 0), +(43, 'Barry', 'Tone', 'btone@myisp.net', '$2y$10$5f4cMkdMuOvx7nebpEWJNOvNLyeDbCWE6HRnQmm0x1.frZw2/pmDy', '2018-05-31 17:11:11', 0), +(44, 'Helen', 'Back', 'hback@myisp.net', '$2y$10$uRQYFnrANSWR7VFu4zUOH.KwwvV/9cEbbQo6KlRakC94SamEC9SO2', '2018-05-31 17:12:02', 0), +(45, 'Justin', 'Case', 'jcase@myisp.co.uk', '$2y$10$n3/2E6ktCuT2xzSZ6cRhAuLUxe3ZaUdPlmkhDj2egeU7ffjj2FGZS', '2018-05-31 17:12:52', 0), +(46, 'Jerry', 'Attrik', 'jattrik@myisp.com', '$2y$10$7CibFWAgTBvB5PHanwTvjOJZTc.3/i6YR055q4gxjQ4X834KxHa6G', '2018-05-31 17:13:55', 0), +(47, 'James', 'Smith', 'jimsmith@myisp.org.uk', '$2y$10$DFVql/p1AkUsNRaajux1zuuR7NEaPdHjT1.Aur5mUt3m/gUZkEUnO', '2018-06-01 14:24:00', 0), +(48, 'James', 'Smith', 'James.smith@myisp.com', '$2y$10$FNg963aulhjXoWUZZvBhwuD41mAY5he4glifJLZy1aGlsjzu7zkLu', '2018-06-01 14:24:46', 0), +(49, 'James', 'Smith', 'Jimmy.smith@myisp.co.uk', '$2y$10$641BVhWNl/WbS7LxHaI9Hemou9tGXa4OKwm4yAFHiSllYUpGRF172', '2018-06-01 14:25:38', 0), +(50, 'James', 'Smith', 'jims@myisp.net', '$2y$10$49UnXz7NG/rJQbH5VmhPzeoBhGJO6HmknCdbqXmYV2/7pbzdBlXBy', '2018-06-01 14:26:32', 0), +(52, 'Phyllis', 'Tine', 'ptine@myisp.co.uk', '$2y$10$gJO4wgQwGdZ3/CylK7LtbOgOiXJBYOw1KflYI/Tk8ExGAJ7CzwA/O', '2018-06-02 13:13:40', 0); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=53; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch04/admintable/admintable/change-password.php b/Ch04/admintable/admintable/change-password.php new file mode 100644 index 0000000..da7b024 --- /dev/null +++ b/Ch04/admintable/admintable/change-password.php @@ -0,0 +1,101 @@ + + + + Change Password + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo ' +
    + + diff --git a/Ch04/admintable/admintable/delete_user.php b/Ch04/admintable/admintable/delete_user.php new file mode 100644 index 0000000..2f43fae --- /dev/null +++ b/Ch04/admintable/admintable/delete_user.php @@ -0,0 +1,53 @@ + + + + + Delete Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/edit_user.php b/Ch04/admintable/admintable/edit_user.php new file mode 100644 index 0000000..4e58279 --- /dev/null +++ b/Ch04/admintable/admintable/edit_user.php @@ -0,0 +1,53 @@ + + + + + Edit Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/footer.php b/Ch04/admintable/admintable/footer.php new file mode 100644 index 0000000..4ccb7e8 --- /dev/null +++ b/Ch04/admintable/admintable/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2018 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch04/admintable/admintable/header-admin.php b/Ch04/admintable/admintable/header-admin.php new file mode 100644 index 0000000..6d014af --- /dev/null +++ b/Ch04/admintable/admintable/header-admin.php @@ -0,0 +1,14 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch04/admintable/admintable/header-members.php b/Ch04/admintable/admintable/header-members.php new file mode 100644 index 0000000..3bf6406 --- /dev/null +++ b/Ch04/admintable/admintable/header-members.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch04/admintable/admintable/header-thanks.php b/Ch04/admintable/admintable/header-thanks.php new file mode 100644 index 0000000..b0b0b07 --- /dev/null +++ b/Ch04/admintable/admintable/header-thanks.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + + diff --git a/Ch04/admintable/admintable/header.php b/Ch04/admintable/admintable/header.php new file mode 100644 index 0000000..92bb26a --- /dev/null +++ b/Ch04/admintable/admintable/header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch04/admintable/admintable/index.php b/Ch04/admintable/admintable/index.php new file mode 100644 index 0000000..e577826 --- /dev/null +++ b/Ch04/admintable/admintable/index.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/info-col.php b/Ch04/admintable/admintable/info-col.php new file mode 100644 index 0000000..1c1ae88 --- /dev/null +++ b/Ch04/admintable/admintable/info-col.php @@ -0,0 +1,3 @@ +

    This is the information column

    +

    Information area

    + diff --git a/Ch04/admintable/admintable/login-header.php b/Ch04/admintable/admintable/login-header.php new file mode 100644 index 0000000..9602ddc --- /dev/null +++ b/Ch04/admintable/admintable/login-header.php @@ -0,0 +1,13 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch04/admintable/admintable/login.php b/Ch04/admintable/admintable/login.php new file mode 100644 index 0000000..bc3d8b3 --- /dev/null +++ b/Ch04/admintable/admintable/login.php @@ -0,0 +1,83 @@ + + + + Login page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Login

    +
    +
    + +
    + +
    +
    +
    + +
    + +  Between 8 and 12 characters.

    +
    +
    +
    +
    + +
    +
    +
    +
    + + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch04/admintable/admintable/logo.jpg b/Ch04/admintable/admintable/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch04/admintable/admintable/logo.jpg differ diff --git a/Ch04/admintable/admintable/logout.php b/Ch04/admintable/admintable/logout.php new file mode 100644 index 0000000..d8abea1 --- /dev/null +++ b/Ch04/admintable/admintable/logout.php @@ -0,0 +1,18 @@ + + + + +Members page + + + + + + +
    +
    + +
    + + +
    +Welcome to the Members Page!'; +?> +
    +
    +

    Member's Events

    +

    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +

    +
    +
    +

    Special offers to members only.

    +

    T-Shirts £10.00

    +Polo shirt
    +
    +
    +
    +

    >
    + + + + diff --git a/Ch04/admintable/admintable/mysqli_connect.php b/Ch04/admintable/admintable/mysqli_connect.php new file mode 100644 index 0000000..ba1b280 --- /dev/null +++ b/Ch04/admintable/admintable/mysqli_connect.php @@ -0,0 +1,11 @@ + + Home + + + + + \ No newline at end of file diff --git a/Ch04/admintable/admintable/password-header.php b/Ch04/admintable/admintable/password-header.php new file mode 100644 index 0000000..e6fc6c8 --- /dev/null +++ b/Ch04/admintable/admintable/password-header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch04/admintable/admintable/process-change-password.php b/Ch04/admintable/admintable/process-change-password.php new file mode 100644 index 0000000..f40f461 --- /dev/null +++ b/Ch04/admintable/admintable/process-change-password.php @@ -0,0 +1,110 @@ + + You could not change password due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + // include footer then close program to stop execution + echo ''; + exit(); + } + } else { // Invalid email address/password combination. + $errorstring = 'Error!
    '; + $errorstring .= 'The email address and/or password do not match those on file.'; + $errorstring .= " Please try again."; + echo "

    $errorstring

    "; +} } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. + //header ("location: register-page.php"); + $errorstring = "Error! The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> + + + + + + + diff --git a/Ch04/admintable/admintable/process-login.php b/Ch04/admintable/admintable/process-login.php new file mode 100644 index 0000000..e014b3f --- /dev/null +++ b/Ch04/admintable/admintable/process-login.php @@ -0,0 +1,83 @@ + The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (!empty($errors)) IF. +mysqli_stmt_free_result($q); +mysqli_stmt_close($q); +} + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +} // no else to allow user to enter values +?> \ No newline at end of file diff --git a/Ch04/admintable/admintable/process-register-page.php b/Ch04/admintable/admintable/process-register-page.php new file mode 100644 index 0000000..777059b --- /dev/null +++ b/Ch04/admintable/admintable/process-register-page.php @@ -0,0 +1,85 @@ +"; + $errorstring .= "System Error
    You could not be registered due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + mysqli_close($dbcon); // Close the database connection. + // include footer then close program to stop execution + echo ''; + exit(); + } + } else { // Report the errors. + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. + } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> \ No newline at end of file diff --git a/Ch04/admintable/admintable/process_admin_view_users.php b/Ch04/admintable/admintable/process_admin_view_users.php new file mode 100644 index 0000000..5e61925 --- /dev/null +++ b/Ch04/admintable/admintable/process_admin_view_users.php @@ -0,0 +1,129 @@ + $pagerows){ //if the number of records will fill more than one page +//Calculate the number of pages and round the result up to the nearest integer +$pages = ceil ($records/$pagerows); // +}else{ +$pages = 1; +} +}//page check finished +//Declare which record to start with +if ((isset($_GET['s'])) &&( is_numeric($_GET['s']))) +{ +$start = htmlspecialchars($_GET['s'], ENT_QUOTES); +// make sure it is not executable XSS +}else{ +$start = 0; +} +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users ORDER BY registration_date ASC"; +$query .=" LIMIT ?, ?"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind $id to SQL Statement +mysqli_stmt_bind_param($q, "ii", $start, $pagerows); + +// execute query + +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran OK (records were returned), display the records. +// Table header. #2 +echo ' + + + + + + + +'; +// Fetch and print all the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of else ($result) +// Now display the total number of records/members. +$q = "SELECT COUNT(userid) FROM users"; +$result = mysqli_query ($dbcon, $q); +$row = mysqli_fetch_array ($result, MYSQLI_NUM); +$members = htmlspecialchars($row[0], ENT_QUOTES); +mysqli_close($dbcon); // Close the database connection. +$echostring = "

    Total membership: $members

    "; +$echostring .= "

    "; +if ($pages > 1) {// +//What number is the current page? +$current_page = ($start/$pagerows) + 1; +//If the page is not the first page then create a Previous link +if ($current_page != 1) { +$echostring .= 'Previous '; +} +//Create a Next link +if ($current_page != $pages) { +$echostring .= ' Next '; +} +$echostring .= '

    '; +echo $echostring; +} +//} +//mysqli_close($dbcon); // Close the database connection. +} //end of try +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> \ No newline at end of file diff --git a/Ch04/admintable/admintable/process_delete_record.php b/Ch04/admintable/admintable/process_delete_record.php new file mode 100644 index 0000000..1b31598 --- /dev/null +++ b/Ch04/admintable/admintable/process_delete_record.php @@ -0,0 +1,95 @@ +The record has been deleted.'; + } else { // If the query did not run OK display public message + echo '

    The record could not be deleted.'; + echo '
    Either it does not exist or due to a system error.

    '; + // echo '

    ' . mysqli_error($dbcon ) . '
    Query: ' . $q . '

    '; + // Debugging message. When live comment out because this displays sql + } + } else { // User did not confirm deletion. + echo '

    The user has NOT been deleted as you requested

    '; + } +} else { // Show the form. #3 + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT CONCAT(first_name, ' ', last_name) FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $id); + + // execute query + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); // get user info + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + + // Display the record being deleted: + $user = htmlspecialchars($row[0], ENT_QUOTES); +?> +

    + Are you sure you want to permanently delete ?

    +
    +
    + +
    + + - + +
    +
    +
    '; +This page has been accessed in error.

    '; + echo '

     

    '; + } +} // End of the main submission conditional. +mysqli_stmt_close($q); +mysqli_close($dbcon ); +} +catch(Exception $e) +{ + print "The system is busy. Please try again."; + //print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is currently busy. Please try again soon."; + //print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch04/admintable/admintable/process_edit_record.php b/Ch04/admintable/admintable/process_edit_record.php new file mode 100644 index 0000000..70234ef --- /dev/null +++ b/Ch04/admintable/admintable/process_edit_record.php @@ -0,0 +1,156 @@ +This page has been accessed in error.

    '; + include ('footer.php'); + exit(); +} + +require ('./mysqli_connect.php'); +// Has the form been submitted? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); + // Look for the first name: + $first_name = filter_var( $_POST['first_name'], FILTER_SANITIZE_STRING); + if (empty($first_name)) { + $errors[] = 'You forgot to enter your first name.'; + } + // Look for the last name: + $last_name = filter_var( $_POST['last_name'], FILTER_SANITIZE_STRING); + if (empty($last_name)) { + $errors[] = 'You forgot to enter your last name.'; + } + // Look for the email address: + $email = filter_var( $_POST['email'], FILTER_SANITIZE_EMAIL); + if ((empty($email)) || (!filter_var($email, FILTER_VALIDATE_EMAIL))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } + if (empty($errors)) { // If everything's OK. #2 + $q = mysqli_stmt_init($dbcon); + $query = 'SELECT userid FROM users WHERE email=? AND userid !=?'; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'si', $email, $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + + if (mysqli_num_rows($result) == 0) { // e-mail does not exist in another record + $query = 'UPDATE users SET first_name=?, last_name=?, email=?'; + $query .= ' WHERE userid=? LIMIT 1'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'sssi', $first_name, $last_name, $email, $id); + // execute query + + mysqli_stmt_execute($q); + + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited.

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited due to a system error.'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } else { // Already registered. + echo '

    The email address has already been registered.

    '; + } + } else { // Display the errors. + echo '

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Echo each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.

    '; + } // End of if (empty($errors))section. +} // End of the conditionals +// Select the user's information to display in textboxes: #3 + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT first_name, last_name, email FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + + $row = mysqli_fetch_array($result, MYSQLI_NUM); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + + // Create the form: +?> +

    Edit Record

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +This page has been accessed in error.

    '; +} +mysqli_stmt_free_result($q); +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy. Please try later"; + //print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is currently busy. Please try again later"; + //print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch04/admintable/admintable/process_temp_view_found_record.php b/Ch04/admintable/admintable/process_temp_view_found_record.php new file mode 100644 index 0000000..0d7bf25 --- /dev/null +++ b/Ch04/admintable/admintable/process_temp_view_found_record.php @@ -0,0 +1,70 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; + +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users WHERE "; +$query .= "last_name='Smith' AND first_name='James' "; +$query .="ORDER BY registration_date ASC "; +// Perpared statement not needed because string is hard coded +$result = mysqli_query ($dbcon, $query); // Run the query. +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "The system is currently busy. Please try later."; +//print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ +print "The system us busy. Please try later."; +//print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch04/admintable/admintable/process_view_found_record.php b/Ch04/admintable/admintable/process_view_found_record.php new file mode 100644 index 0000000..def6abf --- /dev/null +++ b/Ch04/admintable/admintable/process_view_found_record.php @@ -0,0 +1,82 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; +$first_name = htmlspecialchars($_POST['first_name'], ENT_QUOTES); +$last_name = htmlspecialchars($_POST['last_name'], ENT_QUOTES); +// Since it's a prepared statement below this sanitizing is not needed +// However, to consistantly retrieve than sanitize is a good habit +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users WHERE "; +$query .= "last_name=? AND first_name=? "; +$query .="ORDER BY registration_date ASC "; +// Prepared statement not needed because string is hard coded +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +mysqli_stmt_bind_param($q, 'ss', $last_name, $first_name); + +// execute query +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "The system is currently busy. Please try later."; +//print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ +print "The system us busy. Please try later."; +//print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch04/admintable/admintable/register-header.php b/Ch04/admintable/admintable/register-header.php new file mode 100644 index 0000000..1a24c07 --- /dev/null +++ b/Ch04/admintable/admintable/register-header.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch04/admintable/admintable/register-page.php b/Ch04/admintable/admintable/register-page.php new file mode 100644 index 0000000..3d419c7 --- /dev/null +++ b/Ch04/admintable/admintable/register-page.php @@ -0,0 +1,108 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch04/admintable/admintable/register-password.php b/Ch04/admintable/admintable/register-password.php new file mode 100644 index 0000000..0e6f68c --- /dev/null +++ b/Ch04/admintable/admintable/register-password.php @@ -0,0 +1,101 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo ' +
    + + diff --git a/Ch04/admintable/admintable/register-thanks.php b/Ch04/admintable/admintable/register-thanks.php new file mode 100644 index 0000000..fb520c1 --- /dev/null +++ b/Ch04/admintable/admintable/register-thanks.php @@ -0,0 +1,45 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +On the Home Page, you will now be able to login and add new quotes to the message board. +
    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/register-view-users.php b/Ch04/admintable/admintable/register-view-users.php new file mode 100644 index 0000000..2859874 --- /dev/null +++ b/Ch04/admintable/admintable/register-view-users.php @@ -0,0 +1,93 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/search.php b/Ch04/admintable/admintable/search.php new file mode 100644 index 0000000..0cc9fac --- /dev/null +++ b/Ch04/admintable/admintable/search.php @@ -0,0 +1,90 @@ + + + + + Search Page + + + + + + +
    + +
    + +
    + +
    + + +
    +

    Search for a record

    +
    Both names are required items
    +
    +
    + +
    + " > +
    +
    +
    + +
    + "> +
    +
    +
    + +
    + +
    +
    +
    +
    + + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch04/admintable/admintable/temp_view_found_record.php b/Ch04/admintable/admintable/temp_view_found_record.php new file mode 100644 index 0000000..951315e --- /dev/null +++ b/Ch04/admintable/admintable/temp_view_found_record.php @@ -0,0 +1,55 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are found users

    +

    + +

    + + +
    + + +
    + + diff --git a/Ch04/admintable/admintable/thanks-header.php b/Ch04/admintable/admintable/thanks-header.php new file mode 100644 index 0000000..7a0b906 --- /dev/null +++ b/Ch04/admintable/admintable/thanks-header.php @@ -0,0 +1,11 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch04/admintable/admintable/verify.js b/Ch04/admintable/admintable/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch04/admintable/admintable/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch04/admintable/admintable/view_found_record.php b/Ch04/admintable/admintable/view_found_record.php new file mode 100644 index 0000000..94edc12 --- /dev/null +++ b/Ch04/admintable/admintable/view_found_record.php @@ -0,0 +1,55 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are users found

    +

    + +

    + + +
    + + +
    + + diff --git a/Ch05/postal/admin-page.php b/Ch05/postal/admin-page.php new file mode 100644 index 0000000..e4ccc1d --- /dev/null +++ b/Ch05/postal/admin-page.php @@ -0,0 +1,57 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Administration Page

    +

    You have permission to:

    +

    ■Edit and Delete a record

    +

    ■Use the View Members button to page through all the members

    +

    ■Use the Search button to locate a particular member

    +

    ■Use the New Password button to change your password. +

    +
    + + +
    + + +
    + + diff --git a/Ch05/postal/admin-view-users.php b/Ch05/postal/admin-view-users.php new file mode 100644 index 0000000..8e4f50b --- /dev/null +++ b/Ch05/postal/admin-view-users.php @@ -0,0 +1,121 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + + +Edit +Delete +Last Name +First Name +Email +Date Registered +'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to #5 + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + Edit + Delete + ' . $last_name . ' + ' . $first_name . ' + ' . $email . ' + ' . $registration_date . ' + '; + } + echo ''; // Close the table. + // #7 + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + + +
    + + diff --git a/Ch05/postal/admin_view_users.php b/Ch05/postal/admin_view_users.php new file mode 100644 index 0000000..82ffa0c --- /dev/null +++ b/Ch05/postal/admin_view_users.php @@ -0,0 +1,51 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +

    +
    + + +
    + + diff --git a/Ch05/postal/change-password.php b/Ch05/postal/change-password.php new file mode 100644 index 0000000..da7b024 --- /dev/null +++ b/Ch05/postal/change-password.php @@ -0,0 +1,101 @@ + + + + Change Password + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo ' +
    + + diff --git a/Ch05/postal/delete_user.php b/Ch05/postal/delete_user.php new file mode 100644 index 0000000..2f43fae --- /dev/null +++ b/Ch05/postal/delete_user.php @@ -0,0 +1,53 @@ + + + + + Delete Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + + +
    + + diff --git a/Ch05/postal/edit_user.php b/Ch05/postal/edit_user.php new file mode 100644 index 0000000..b2396a1 --- /dev/null +++ b/Ch05/postal/edit_user.php @@ -0,0 +1,53 @@ + + + + + Edit a Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + + +
    + + diff --git a/Ch05/postal/footer.php b/Ch05/postal/footer.php new file mode 100644 index 0000000..4ccb7e8 --- /dev/null +++ b/Ch05/postal/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2018 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch05/postal/header-admin.php b/Ch05/postal/header-admin.php new file mode 100644 index 0000000..d9f4072 --- /dev/null +++ b/Ch05/postal/header-admin.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch05/postal/header-members.php b/Ch05/postal/header-members.php new file mode 100644 index 0000000..3bf6406 --- /dev/null +++ b/Ch05/postal/header-members.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch05/postal/header-thanks.php b/Ch05/postal/header-thanks.php new file mode 100644 index 0000000..b0b0b07 --- /dev/null +++ b/Ch05/postal/header-thanks.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + + diff --git a/Ch05/postal/header.php b/Ch05/postal/header.php new file mode 100644 index 0000000..92bb26a --- /dev/null +++ b/Ch05/postal/header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch05/postal/images/Thumbs.db b/Ch05/postal/images/Thumbs.db new file mode 100644 index 0000000..36a1b2f Binary files /dev/null and b/Ch05/postal/images/Thumbs.db differ diff --git a/Ch05/postal/images/polo.png b/Ch05/postal/images/polo.png new file mode 100644 index 0000000..bca2bd2 Binary files /dev/null and b/Ch05/postal/images/polo.png differ diff --git a/Ch05/postal/images/tile-pale.jpg b/Ch05/postal/images/tile-pale.jpg new file mode 100644 index 0000000..ae45d50 Binary files /dev/null and b/Ch05/postal/images/tile-pale.jpg differ diff --git a/Ch05/postal/images/vertical_solution_PP.png b/Ch05/postal/images/vertical_solution_PP.png new file mode 100644 index 0000000..8693bd4 Binary files /dev/null and b/Ch05/postal/images/vertical_solution_PP.png differ diff --git a/Ch05/postal/index.php b/Ch05/postal/index.php new file mode 100644 index 0000000..e577826 --- /dev/null +++ b/Ch05/postal/index.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + + +
    + + diff --git a/Ch05/postal/info-col-cards.php b/Ch05/postal/info-col-cards.php new file mode 100644 index 0000000..05671fc --- /dev/null +++ b/Ch05/postal/info-col-cards.php @@ -0,0 +1,4 @@ + +

    Payment Methods

    + Pay by PayPal or Credit card + diff --git a/Ch05/postal/info-col.php b/Ch05/postal/info-col.php new file mode 100644 index 0000000..1c1ae88 --- /dev/null +++ b/Ch05/postal/info-col.php @@ -0,0 +1,3 @@ +

    This is the information column

    +

    Information area

    + diff --git a/Ch05/postal/login-header.php b/Ch05/postal/login-header.php new file mode 100644 index 0000000..9602ddc --- /dev/null +++ b/Ch05/postal/login-header.php @@ -0,0 +1,13 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch05/postal/login.php b/Ch05/postal/login.php new file mode 100644 index 0000000..bc3d8b3 --- /dev/null +++ b/Ch05/postal/login.php @@ -0,0 +1,83 @@ + + + + Login page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Login

    +
    +
    + +
    + +
    +
    +
    + +
    + +  Between 8 and 12 characters.

    +
    +
    +
    +
    + +
    +
    +
    +
    + + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch05/postal/logo.jpg b/Ch05/postal/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch05/postal/logo.jpg differ diff --git a/Ch05/postal/logout.php b/Ch05/postal/logout.php new file mode 100644 index 0000000..d8abea1 --- /dev/null +++ b/Ch05/postal/logout.php @@ -0,0 +1,18 @@ + +Logo + +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch05/postal/members-page.php b/Ch05/postal/members-page.php new file mode 100644 index 0000000..e6252d1 --- /dev/null +++ b/Ch05/postal/members-page.php @@ -0,0 +1,61 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Member's Page

    +

    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +

    +

    Special offers to members only.

    +

    T-Shirts 10.00

    +Polo Shirt +
    +
    + + +
    + + +
    + + + diff --git a/Ch05/postal/mysqli_connect.php b/Ch05/postal/mysqli_connect.php new file mode 100644 index 0000000..70bf5fc --- /dev/null +++ b/Ch05/postal/mysqli_connect.php @@ -0,0 +1,11 @@ + + Home + + + + + \ No newline at end of file diff --git a/Ch05/postal/password-header.php b/Ch05/postal/password-header.php new file mode 100644 index 0000000..e6fc6c8 --- /dev/null +++ b/Ch05/postal/password-header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch05/postal/postaldb.sql b/Ch05/postal/postaldb.sql new file mode 100644 index 0000000..89a92b5 --- /dev/null +++ b/Ch05/postal/postaldb.sql @@ -0,0 +1,109 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 06:56 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `postaldb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prices` +-- + +CREATE TABLE `prices` ( + `oneyeargb` decimal(6,0) NOT NULL, + `oneyearus` decimal(6,0) NOT NULL, + `fiveyeargb` decimal(6,0) NOT NULL, + `fiveyearus` decimal(6,0) NOT NULL, + `militarygb` decimal(6,0) NOT NULL, + `militaryus` decimal(6,0) NOT NULL, + `u21gb` decimal(6,0) NOT NULL, + `u21us` decimal(6,0) NOT NULL, + `minpricegb` decimal(6,0) NOT NULL, + `minpriceus` decimal(6,0) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dumping data for table `prices` +-- + +INSERT INTO `prices` (`oneyeargb`, `oneyearus`, `fiveyeargb`, `fiveyearus`, `militarygb`, `militaryus`, `u21gb`, `u21us`, `minpricegb`, `minpriceus`) VALUES +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `first_name` varchar(30) COLLATE utf8_bin NOT NULL, + `last_name` varchar(40) COLLATE utf8_bin NOT NULL, + `email` varchar(50) COLLATE utf8_bin NOT NULL, + `password` char(60) COLLATE utf8_bin NOT NULL, + `registration_date` datetime NOT NULL, + `user_level` tinyint(1) NOT NULL, + `address1` varchar(50) COLLATE utf8_bin NOT NULL, + `address2` varchar(50) COLLATE utf8_bin DEFAULT NULL, + `city` varchar(50) COLLATE utf8_bin NOT NULL, + `state_country` char(25) COLLATE utf8_bin NOT NULL, + `zcode_pcode` char(10) COLLATE utf8_bin NOT NULL, + `phone` char(15) COLLATE utf8_bin DEFAULT NULL, + `paid` enum('No','Yes') COLLATE utf8_bin NOT NULL, + `class` char(20) COLLATE utf8_bin NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `user_level`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `paid`, `class`) VALUES +(1, 'James', 'Smith', 'jsmith@myisp.com', '$2y$10$9A7tLasMBRhpgHGXvAR3o.7o9TTl8MCI90FjVqe2NxtreSqMwU5Ze', '2017-12-08 18:13:48', 1, '2 The Street', NULL, 'Townsville', 'CA', '33040', '3055551111', 'No', '125'), +(2, 'Jack', 'Smith', 'jsmith@outcook.com', '$2y$10$7bRW0hJkQFQs6QKxLYm4Cud/Mq0/opjEGLdLPECCWoi9EScVLNg32', '2017-12-08 18:18:35', 0, '2 The Street', NULL, 'Townsville', 'CA', '33040', '3055551111', 'No', '30'), +(3, 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$2ozl5Ds/F.IdEDGnfAovku5DxQubPbzxfeFKCpZDsi74wLEmeCeSy', '2017-12-08 18:19:43', 0, '2 The Street', NULL, 'Townsville', 'CA', '33040', '3055551111', 'No', '2'), +(4, 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$IiCEJot1JJ3X2WUjAx9e4ecQL2eUbBsCbUqNwljgxrX7cLtKebpAe', '2017-12-08 18:21:08', 0, '2 The Street', 'The Village', 'Townsville', 'CA', '33040', '3055551111', 'No', '2'), +(5, 'Frank', 'Incense', 'incense@myisp.net', '$2y$10$Tm6mFieRmBMAXPS4VqE.aubkadLmW2clnrDkTS3ZKbyXFvlNBkZzu', '2017-12-08 18:22:53', 0, '2 The Street', 'The Village', 'Townsville', 'CA', '33040', NULL, 'No', '15'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch05/postal/process-change-password.php b/Ch05/postal/process-change-password.php new file mode 100644 index 0000000..f40f461 --- /dev/null +++ b/Ch05/postal/process-change-password.php @@ -0,0 +1,110 @@ + + You could not change password due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + // include footer then close program to stop execution + echo ''; + exit(); + } + } else { // Invalid email address/password combination. + $errorstring = 'Error!
    '; + $errorstring .= 'The email address and/or password do not match those on file.'; + $errorstring .= " Please try again."; + echo "

    $errorstring

    "; +} } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. + //header ("location: register-page.php"); + $errorstring = "Error! The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> + + + + + + + diff --git a/Ch05/postal/process-login.php b/Ch05/postal/process-login.php new file mode 100644 index 0000000..139ac70 --- /dev/null +++ b/Ch05/postal/process-login.php @@ -0,0 +1,86 @@ + The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (!empty($errors)) IF. +mysqli_stmt_free_result($q); +mysqli_stmt_close($q); +} + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +} // no else to allow user to enter values +?> \ No newline at end of file diff --git a/Ch05/postal/process-register-page.php b/Ch05/postal/process-register-page.php new file mode 100644 index 0000000..93916e2 --- /dev/null +++ b/Ch05/postal/process-register-page.php @@ -0,0 +1,144 @@ +"; + $errorstring .= "System Error
    You could not be registered due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + mysqli_close($dbcon); // Close the database connection. + // include footer then close program to stop execution + echo ''; + exit(); + } + }else{//The email address is already registered #4 + $errorstring = 'The email address is already registered.'; + echo "

    $errorstring

    "; + } + } else { // Report the errors. + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. + } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> \ No newline at end of file diff --git a/Ch05/postal/process_admin_view_users.php b/Ch05/postal/process_admin_view_users.php new file mode 100644 index 0000000..5e61925 --- /dev/null +++ b/Ch05/postal/process_admin_view_users.php @@ -0,0 +1,129 @@ + $pagerows){ //if the number of records will fill more than one page +//Calculate the number of pages and round the result up to the nearest integer +$pages = ceil ($records/$pagerows); // +}else{ +$pages = 1; +} +}//page check finished +//Declare which record to start with +if ((isset($_GET['s'])) &&( is_numeric($_GET['s']))) +{ +$start = htmlspecialchars($_GET['s'], ENT_QUOTES); +// make sure it is not executable XSS +}else{ +$start = 0; +} +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users ORDER BY registration_date ASC"; +$query .=" LIMIT ?, ?"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind $id to SQL Statement +mysqli_stmt_bind_param($q, "ii", $start, $pagerows); + +// execute query + +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran OK (records were returned), display the records. +// Table header. #2 +echo ' + + + + + + + +'; +// Fetch and print all the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of else ($result) +// Now display the total number of records/members. +$q = "SELECT COUNT(userid) FROM users"; +$result = mysqli_query ($dbcon, $q); +$row = mysqli_fetch_array ($result, MYSQLI_NUM); +$members = htmlspecialchars($row[0], ENT_QUOTES); +mysqli_close($dbcon); // Close the database connection. +$echostring = "

    Total membership: $members

    "; +$echostring .= "

    "; +if ($pages > 1) {// +//What number is the current page? +$current_page = ($start/$pagerows) + 1; +//If the page is not the first page then create a Previous link +if ($current_page != 1) { +$echostring .= 'Previous '; +} +//Create a Next link +if ($current_page != $pages) { +$echostring .= ' Next '; +} +$echostring .= '

    '; +echo $echostring; +} +//} +//mysqli_close($dbcon); // Close the database connection. +} //end of try +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> \ No newline at end of file diff --git a/Ch05/postal/process_delete_record.php b/Ch05/postal/process_delete_record.php new file mode 100644 index 0000000..1b31598 --- /dev/null +++ b/Ch05/postal/process_delete_record.php @@ -0,0 +1,95 @@ +The record has been deleted.'; + } else { // If the query did not run OK display public message + echo '

    The record could not be deleted.'; + echo '
    Either it does not exist or due to a system error.

    '; + // echo '

    ' . mysqli_error($dbcon ) . '
    Query: ' . $q . '

    '; + // Debugging message. When live comment out because this displays sql + } + } else { // User did not confirm deletion. + echo '

    The user has NOT been deleted as you requested

    '; + } +} else { // Show the form. #3 + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT CONCAT(first_name, ' ', last_name) FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $id); + + // execute query + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); // get user info + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + + // Display the record being deleted: + $user = htmlspecialchars($row[0], ENT_QUOTES); +?> +

    + Are you sure you want to permanently delete ?

    +
    +
    + +
    + + - + +
    +
    +
    '; +This page has been accessed in error.

    '; + echo '

     

    '; + } +} // End of the main submission conditional. +mysqli_stmt_close($q); +mysqli_close($dbcon ); +} +catch(Exception $e) +{ + print "The system is busy. Please try again."; + //print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is currently busy. Please try again soon."; + //print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch05/postal/process_edit_record.php b/Ch05/postal/process_edit_record.php new file mode 100644 index 0000000..8d5899f --- /dev/null +++ b/Ch05/postal/process_edit_record.php @@ -0,0 +1,187 @@ +This page has been accessed in error.

    '; + include ('footer.php'); + exit(); +} + +require ('./mysqli_connect.php'); +// Has the form been submitted? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); + // Look for the first name: + $first_name = filter_var( $_POST['first_name'], FILTER_SANITIZE_STRING); + if (empty($first_name)) { + $errors[] = 'You forgot to enter your first name.'; + } + // Look for the last name: + $last_name = filter_var( $_POST['last_name'], FILTER_SANITIZE_STRING); + if (empty($last_name)) { + $errors[] = 'You forgot to enter your last name.'; + } + // Look for the email address: + $email = filter_var( $_POST['email'], FILTER_SANITIZE_EMAIL); + if ((empty($email)) || (!filter_var($email, FILTER_VALIDATE_EMAIL))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } + // Look for class: + $class = filter_var( $_POST['class'], FILTER_SANITIZE_NUMBER_INT); + if (empty($class)) { + $errors[] = 'You forgot to the class or it is not numeric.'; + } + // Look for the Paid Status: + $paid = filter_var( $_POST['paid'], FILTER_SANITIZE_STRING); + if (empty($paid)) { + $errors[] = 'You forgot to enter the paid status.'; + } + if (!($paid == "No") || ($paid == "Yes")) { + $errors[] = "Paid must be No or Yes."; + } + if (empty($errors)) { // If everything's OK. + $q = mysqli_stmt_init($dbcon); + $query = 'SELECT userid FROM users WHERE email=? AND userid !=?'; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'si', $email, $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + + if (mysqli_num_rows($result) == 0) { // e-mail does not exist in another record + $query = 'UPDATE users SET first_name=?, last_name=?, email=?,'; + $query .= ' class=?, paid=?'; + $query .= ' WHERE userid=? LIMIT 1'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'sssssi', $first_name, $last_name, $email, $class, $paid, $id); + // execute query + + mysqli_stmt_execute($q); + + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited.

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited due to a system error.'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } else { // Already registered. + echo '

    The email address has already been registered.

    '; + } + } else { // Display the errors. + echo '

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Echo each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.

    '; + } // End of if (empty($errors))section. +} // End of the conditionals +// Select the user's information to display in textboxes: #3 + + $q = mysqli_stmt_init($dbcon); + $query = + "SELECT first_name, last_name, email, class, paid FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + + $row = mysqli_fetch_array($result, MYSQLI_NUM); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + + // Create the form: +?> +

    Edit a Record

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +This page has been accessed in error.

    '; +} +mysqli_stmt_free_result($q); +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy. Please try later"; + //print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is currently busy. Please try again later"; + //print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch05/postal/process_temp_view_found_record.php b/Ch05/postal/process_temp_view_found_record.php new file mode 100644 index 0000000..0d7bf25 --- /dev/null +++ b/Ch05/postal/process_temp_view_found_record.php @@ -0,0 +1,70 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; + +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users WHERE "; +$query .= "last_name='Smith' AND first_name='James' "; +$query .="ORDER BY registration_date ASC "; +// Perpared statement not needed because string is hard coded +$result = mysqli_query ($dbcon, $query); // Run the query. +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "The system is currently busy. Please try later."; +//print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ +print "The system us busy. Please try later."; +//print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch05/postal/process_view_found_record.php b/Ch05/postal/process_view_found_record.php new file mode 100644 index 0000000..8bd6b5c --- /dev/null +++ b/Ch05/postal/process_view_found_record.php @@ -0,0 +1,89 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; +$first_name = htmlspecialchars($_POST['first_name'], ENT_QUOTES); +$last_name = htmlspecialchars($_POST['last_name'], ENT_QUOTES); +// Since it's a prepared statement below this sanitizing is not needed +// However, to consistantly retrieve than sanitize is a good habit + +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, class, paid, userid FROM users WHERE "; +$query .= "last_name=? AND first_name=? "; +$query .="ORDER BY registration_date ASC "; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +mysqli_stmt_bind_param($q, 'ss', $last_name, $first_name); + +// execute query +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + $class = htmlspecialchars($row['class'], ENT_QUOTES); + $paid = htmlspecialchars($row['paid'], ENT_QUOTES); + echo ' + + + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate RegisteredClassPaid
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '' . $class . '' . $paid . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "The system is currently busy. Please try later."; +//print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ +print "The system us busy. Please try later."; +//print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch05/postal/register-header.php b/Ch05/postal/register-header.php new file mode 100644 index 0000000..1a24c07 --- /dev/null +++ b/Ch05/postal/register-header.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch05/postal/register-page-new.php b/Ch05/postal/register-page-new.php new file mode 100644 index 0000000..232ab4d --- /dev/null +++ b/Ch05/postal/register-page-new.php @@ -0,0 +1,247 @@ + + + + Register Page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +

    Items marked with an asterisk * are required

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    + + diff --git a/Ch05/postal/register-page.php b/Ch05/postal/register-page.php new file mode 100644 index 0000000..c3e8066 --- /dev/null +++ b/Ch05/postal/register-page.php @@ -0,0 +1,245 @@ + + + + Register Page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +

    Items marked with an asterisk * are required

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('info-col-cards.php'); + echo ''; + echo '
    '; + echo '
    "; + } +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } +catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + ?> + + diff --git a/Ch05/postal/register-password.php b/Ch05/postal/register-password.php new file mode 100644 index 0000000..0e6f68c --- /dev/null +++ b/Ch05/postal/register-password.php @@ -0,0 +1,101 @@ + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo ' +
    + + diff --git a/Ch05/postal/register-thanks.php b/Ch05/postal/register-thanks.php new file mode 100644 index 0000000..fa2c9f7 --- /dev/null +++ b/Ch05/postal/register-thanks.php @@ -0,0 +1,129 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +
    To confirm your registration please verify membership class and pay the membership fee now.
    +
    You can use PayPal or a credit/debit card.
    +

    When you have completed your registration you will be able to login +to the member's only pages.

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +

    +
    + + +
    + +
    + +
    +
    +
    + +
    + + + + + +
    +
    +
    +
    + + +
    + + +getMessage(); + print "The system is busy please try later"; + } +catch(Error $e) +{ + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; +} +?> + + diff --git a/Ch05/postal/register-view-users.php b/Ch05/postal/register-view-users.php new file mode 100644 index 0000000..2859874 --- /dev/null +++ b/Ch05/postal/register-view-users.php @@ -0,0 +1,93 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch05/postal/search.php b/Ch05/postal/search.php new file mode 100644 index 0000000..a9e93da --- /dev/null +++ b/Ch05/postal/search.php @@ -0,0 +1,90 @@ + + + + + Search Page + + + + + + +
    + +
    + +
    + +
    + + +
    +

    Search for a record

    +
    Both names are required items
    +
    +
    + +
    + " > +
    +
    +
    + +
    + "> +
    +
    +
    + +
    + +
    +
    +
    +
    + + +'; + include('info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('footer.php'); + ?> +
    +
    + + diff --git a/Ch05/postal/temp_view_found_record.php b/Ch05/postal/temp_view_found_record.php new file mode 100644 index 0000000..951315e --- /dev/null +++ b/Ch05/postal/temp_view_found_record.php @@ -0,0 +1,55 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are found users

    +

    + +

    + + +
    + +
    + +
    +
    + + diff --git a/Ch05/postal/thanks-header.php b/Ch05/postal/thanks-header.php new file mode 100644 index 0000000..7a0b906 --- /dev/null +++ b/Ch05/postal/thanks-header.php @@ -0,0 +1,11 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch05/postal/verify.js b/Ch05/postal/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch05/postal/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch05/postal/view_found_record.php b/Ch05/postal/view_found_record.php new file mode 100644 index 0000000..1c3c431 --- /dev/null +++ b/Ch05/postal/view_found_record.php @@ -0,0 +1,51 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are users found

    +

    + +

    +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/admin-page.php b/Ch06/finalpostal/admin-page.php new file mode 100644 index 0000000..80aad6c --- /dev/null +++ b/Ch06/finalpostal/admin-page.php @@ -0,0 +1,57 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Administration Page

    +

    You have permission to:

    +

    ■Edit and Delete a record

    +

    ■Use the View Members button to page through all the members

    +

    ■Use the Search button to locate a particular member

    +

    ■Use the New Password button to change your password. +

    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/admin-view-users.php b/Ch06/finalpostal/admin-view-users.php new file mode 100644 index 0000000..4e28c86 --- /dev/null +++ b/Ch06/finalpostal/admin-view-users.php @@ -0,0 +1,121 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + + +Edit +Delete +Last Name +First Name +Email +Date Registered +'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to #5 + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + Edit + Delete + ' . $last_name . ' + ' . $first_name . ' + ' . $email . ' + ' . $registration_date . ' + '; + } + echo ''; // Close the table. + // #7 + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/admin_view_users.php b/Ch06/finalpostal/admin_view_users.php new file mode 100644 index 0000000..0874f76 --- /dev/null +++ b/Ch06/finalpostal/admin_view_users.php @@ -0,0 +1,52 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +

    +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/cap.php b/Ch06/finalpostal/cap.php new file mode 100644 index 0000000..201053b --- /dev/null +++ b/Ch06/finalpostal/cap.php @@ -0,0 +1,17 @@ +Are you human? Click recaptcha"; + header( "refresh:1;" ); + } + } + else { echo "

    Are you human? Click recaptcha!

    "; + header( "refresh:1;" ); + } + +?> \ No newline at end of file diff --git a/Ch06/finalpostal/change-password.php b/Ch06/finalpostal/change-password.php new file mode 100644 index 0000000..eb049c8 --- /dev/null +++ b/Ch06/finalpostal/change-password.php @@ -0,0 +1,115 @@ + + + + Change Password + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch06/finalpostal/delete_user.php b/Ch06/finalpostal/delete_user.php new file mode 100644 index 0000000..9607aef --- /dev/null +++ b/Ch06/finalpostal/delete_user.php @@ -0,0 +1,53 @@ + + + + + Delete Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/edit_address.php b/Ch06/finalpostal/edit_address.php new file mode 100644 index 0000000..d4cb1e1 --- /dev/null +++ b/Ch06/finalpostal/edit_address.php @@ -0,0 +1,53 @@ + + + + + Edit an Address + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/edit_user.php b/Ch06/finalpostal/edit_user.php new file mode 100644 index 0000000..7610f60 --- /dev/null +++ b/Ch06/finalpostal/edit_user.php @@ -0,0 +1,53 @@ + + + + + Edit a Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/finalpostal.sql b/Ch06/finalpostal/finalpostal.sql new file mode 100644 index 0000000..8a97a89 --- /dev/null +++ b/Ch06/finalpostal/finalpostal.sql @@ -0,0 +1,124 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 07:01 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `finalpostal` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prices` +-- + +CREATE TABLE `prices` ( + `oneyeargb` decimal(6,0) UNSIGNED NOT NULL, + `oneyearus` decimal(6,0) UNSIGNED NOT NULL, + `fiveyeargb` decimal(6,0) UNSIGNED NOT NULL, + `fiveyearus` decimal(6,0) UNSIGNED NOT NULL, + `militarygb` decimal(6,0) UNSIGNED NOT NULL, + `militaryus` decimal(6,0) UNSIGNED NOT NULL, + `u21gb` decimal(6,0) UNSIGNED NOT NULL, + `u21us` decimal(6,0) UNSIGNED NOT NULL, + `minpricegb` decimal(6,0) UNSIGNED NOT NULL, + `minpriceus` decimal(6,0) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `prices` +-- + +INSERT INTO `prices` (`oneyeargb`, `oneyearus`, `fiveyeargb`, `fiveyearus`, `militarygb`, `militaryus`, `u21gb`, `u21us`, `minpricegb`, `minpriceus`) VALUES +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `class` char(20) NOT NULL, + `user_level` tinyint(2) UNSIGNED NOT NULL, + `address1` varchar(50) NOT NULL, + `address2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `secret` varchar(30) NOT NULL, + `paid` enum('No','Yes') NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `title`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `class`, `user_level`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `secret`, `paid`) VALUES +(1, 'Mr', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UiiBhmXca.0/bwopveFq8uInuX.EVrecinUQYQG546WjAWwZLJNoe', '2017-12-06 08:43:41', '30', 0, '4 The Street', 'The Village', 'Townsville', 'USA', 'WA', '0123777888', '', 'Yes'), +(2, 'Mr', 'Jack', 'Smith', 'jsmith@outcook.com', '$2y$10$NjlsajfCITeb.oDXqu9Neuguh3PBKL5EaqZ5ClfW76nVSnW.W.XNO', '2017-12-06 08:47:24', '30', 1, '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 'Yes'), +(4, 'Ms', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$5KM8jy5MwHIgfVchsdfE8OvuF1cT2VYqU6mte2CWBw1HjmEv3r.ES', '2017-12-06 12:20:33', '2', 0, '6 The Street', '', 'Townsville', 'UK', 'EX9 9PG', '01234777888', '', 'Yes'), +(5, 'Mr', 'Patrick', 'O\'Hara', 'pohara@myisp.org.uk', '$2y$10$0nmGDVmHdWusgFJRmVZADeL43Y7HCPViBrHj/Z2betxiMdMx5Y2sC', '2017-12-06 12:27:32', '30', 0, '5 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 'Yes'), +(6, 'Mr', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$KCQhEftEJouWPfuOOVoRVOECY/oJTluxHRr85fWlz6nsfN4OHtCie', '2017-12-06 17:02:16', '30', 0, '6 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PS', '', '', 'Yes'), +(7, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$IrQE3TTkWzNm93FP/VYf.O/yMWDJDpIn/.qjrmvN.I97fvakynuza', '2017-12-06 17:11:44', '30', 0, '7 The Street', 'The Village', 'Townsville', 'UK', 'EXP 6PG', '01234777888', '', 'Yes'), +(8, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$R2auBMKMe/Qw2fFr8D.S8eUEENUz8r.YUth5NHAyskNYupUzBen5O', '2017-12-06 17:18:30', '30', 0, '7 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 'Yes'), +(9, 'Mrs', 'Annie', 'Mossity', 'amossity@myisp.org.uk', '$2y$10$amqmyEfaOfiZ0MkIzdO90uZMPw4Mi/4RR70nNd0nxaZSOlxlr.8DC', '2017-12-06 17:24:42', '30', 0, '4 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '', 'Yes'), +(10, 'Mr', 'Percy', 'Veer', 'pveer@myisp.com', '$2y$10$Wvdx/YO4cCcOQvyMVVtapO3F/eiz2Ow3yU9VcczGMC.dcgwbgIXMS', '2017-12-06 17:28:53', '30', 0, '7 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '', 'Yes'), +(11, 'Mr', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$cTmJVcuUmTpCOIdQJ8MG3uwLmG7M7V3iE8zPXiNW2PQEdDQZMBftO', '2017-12-06 17:39:30', '30', 0, '5 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '', '', 'Yes'), +(12, 'Mr', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$YUYnU8UvOF/WUJ5h4VK4Qe.I48ZcAbedjPiDekKHlODduqGdJoI9i', '2017-12-06 18:02:04', '30', 0, '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '', 'Yes'), +(13, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$k9sMvE001164jjzJLs.OpOmb9LtluUEbR4GQ4RT5/rvSPNIqbL6gC', '2017-12-07 17:39:34', '30', 0, '6 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 'Yes'), +(14, 'Mr', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$TOr.IZq/joHIKSk0Oo.jE.yWau48sUSgtC5TzKJ0sl0AoO2Bsk3lW', '2017-12-08 12:16:58', '30', 0, '5 The Street', '', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '', 'Yes'), +(16, 'Miss', 'Lynn', 'Seed', 'lseed@myisp.com', '$2y$10$nEs3Zhh4V5ZznpcPzGs9gOWupjY2NgV87DPpLu2DjqsdyBNRjf4/C', '2017-12-16 20:03:16', '30', 0, '6 The Street', '', 'Townsville', 'UK', 'EX24 6PG', '01234777888', '', 'Yes'), +(17, 'Mr', 'Barry', 'Tone', 'btone@myisp.net', '$2y$10$w4zMq7ij7NmVDeBBKDSmbu963EwchZwAHPZmgZmTQAQ8Gha2jTD5W', '2017-12-16 20:16:40', '30', 0, '2 The Street', '', 'Townsville', 'USA', 'CA12345', '', '', 'Yes'), +(30, 'Mr', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$lePdxFz7ZKn/bJ41BS0h/ehWyIL2ZgK123iPQJahNCaRjgxVY3Rfq', '2017-12-29 11:28:43', '30', 0, '2 The Street', 'The Village', 'Townsville', 'Germany', 'BL1234', '', '', 'Yes'), +(31, 'Miss', 'Dee', 'Jected', 'djected@myisp.org.uk', '$2y$10$ujpV7w4blsTdQFWOsE1fiOFYtj9zN4w0WcK5V4WJ60Pc5HWodWlGC', '2017-12-29 11:48:04', '30', 0, '3 The Street', 'The Village', 'Townsville', 'UK', 'EX3 1TH', '', '', 'Yes'), +(32, 'Mr', 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$Yu.c/cw/TSFa9vcMBGAfAe5vzyOwp3SZarBVc/9vEksfp.F8BzSiW', '2017-12-29 11:58:51', '30', 0, '2 The Street', '', 'Townsville', 'UK', 'EX24 6PS', '01234777888', '', 'Yes'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=38; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch06/finalpostal/images/Thumbs.db b/Ch06/finalpostal/images/Thumbs.db new file mode 100644 index 0000000..04bb756 Binary files /dev/null and b/Ch06/finalpostal/images/Thumbs.db differ diff --git a/Ch06/finalpostal/images/logo.jpg b/Ch06/finalpostal/images/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch06/finalpostal/images/logo.jpg differ diff --git a/Ch06/finalpostal/images/polo.png b/Ch06/finalpostal/images/polo.png new file mode 100644 index 0000000..bca2bd2 Binary files /dev/null and b/Ch06/finalpostal/images/polo.png differ diff --git a/Ch06/finalpostal/images/tile-pale.jpg b/Ch06/finalpostal/images/tile-pale.jpg new file mode 100644 index 0000000..ae45d50 Binary files /dev/null and b/Ch06/finalpostal/images/tile-pale.jpg differ diff --git a/Ch06/finalpostal/images/vertical_solution_PP.png b/Ch06/finalpostal/images/vertical_solution_PP.png new file mode 100644 index 0000000..8693bd4 Binary files /dev/null and b/Ch06/finalpostal/images/vertical_solution_PP.png differ diff --git a/Ch06/finalpostal/includes/footer.php b/Ch06/finalpostal/includes/footer.php new file mode 100644 index 0000000..742b705 --- /dev/null +++ b/Ch06/finalpostal/includes/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2017 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch06/finalpostal/includes/header-admin.php b/Ch06/finalpostal/includes/header-admin.php new file mode 100644 index 0000000..50c305b --- /dev/null +++ b/Ch06/finalpostal/includes/header-admin.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch06/finalpostal/includes/header-members.php b/Ch06/finalpostal/includes/header-members.php new file mode 100644 index 0000000..3bf6406 --- /dev/null +++ b/Ch06/finalpostal/includes/header-members.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch06/finalpostal/includes/header-thanks.php b/Ch06/finalpostal/includes/header-thanks.php new file mode 100644 index 0000000..b0b0b07 --- /dev/null +++ b/Ch06/finalpostal/includes/header-thanks.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + + diff --git a/Ch06/finalpostal/includes/header.php b/Ch06/finalpostal/includes/header.php new file mode 100644 index 0000000..69f9524 --- /dev/null +++ b/Ch06/finalpostal/includes/header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch06/finalpostal/includes/info-col-cards.php b/Ch06/finalpostal/includes/info-col-cards.php new file mode 100644 index 0000000..fda610e --- /dev/null +++ b/Ch06/finalpostal/includes/info-col-cards.php @@ -0,0 +1,4 @@ + +

    Payment Methods

    + Pay by PayPal or Credit card + diff --git a/Ch06/finalpostal/includes/info-col.php b/Ch06/finalpostal/includes/info-col.php new file mode 100644 index 0000000..1c1ae88 --- /dev/null +++ b/Ch06/finalpostal/includes/info-col.php @@ -0,0 +1,3 @@ +

    This is the information column

    +

    Information area

    + diff --git a/Ch06/finalpostal/includes/login-header.php b/Ch06/finalpostal/includes/login-header.php new file mode 100644 index 0000000..9602ddc --- /dev/null +++ b/Ch06/finalpostal/includes/login-header.php @@ -0,0 +1,13 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch06/finalpostal/includes/logo.jpg b/Ch06/finalpostal/includes/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch06/finalpostal/includes/logo.jpg differ diff --git a/Ch06/finalpostal/includes/members-header.php b/Ch06/finalpostal/includes/members-header.php new file mode 100644 index 0000000..de443b4 --- /dev/null +++ b/Ch06/finalpostal/includes/members-header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch06/finalpostal/includes/nav.php b/Ch06/finalpostal/includes/nav.php new file mode 100644 index 0000000..db873ad --- /dev/null +++ b/Ch06/finalpostal/includes/nav.php @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/Ch06/finalpostal/includes/password-header.php b/Ch06/finalpostal/includes/password-header.php new file mode 100644 index 0000000..e6fc6c8 --- /dev/null +++ b/Ch06/finalpostal/includes/password-header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch06/finalpostal/includes/register-header.php b/Ch06/finalpostal/includes/register-header.php new file mode 100644 index 0000000..b1a43e8 --- /dev/null +++ b/Ch06/finalpostal/includes/register-header.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch06/finalpostal/includes/register-thanks.php b/Ch06/finalpostal/includes/register-thanks.php new file mode 100644 index 0000000..fa2c9f7 --- /dev/null +++ b/Ch06/finalpostal/includes/register-thanks.php @@ -0,0 +1,129 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +
    To confirm your registration please verify membership class and pay the membership fee now.
    +
    You can use PayPal or a credit/debit card.
    +

    When you have completed your registration you will be able to login +to the member's only pages.

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +

    +
    + + +
    + +
    + +
    +
    +
    + +
    + + + + + +
    +
    +
    +
    + + +
    + +
    + +
    +getMessage(); + print "The system is busy please try later"; + } +catch(Error $e) +{ + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; +} +?> + + diff --git a/Ch06/finalpostal/includes/thanks-header.php b/Ch06/finalpostal/includes/thanks-header.php new file mode 100644 index 0000000..7a0b906 --- /dev/null +++ b/Ch06/finalpostal/includes/thanks-header.php @@ -0,0 +1,11 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch06/finalpostal/index.php b/Ch06/finalpostal/index.php new file mode 100644 index 0000000..7e9feef --- /dev/null +++ b/Ch06/finalpostal/index.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/login.php b/Ch06/finalpostal/login.php new file mode 100644 index 0000000..955c313 --- /dev/null +++ b/Ch06/finalpostal/login.php @@ -0,0 +1,90 @@ + + + + Login page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Login

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + + +'; + include('includes/info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch06/finalpostal/logo.jpg b/Ch06/finalpostal/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch06/finalpostal/logo.jpg differ diff --git a/Ch06/finalpostal/logout.php b/Ch06/finalpostal/logout.php new file mode 100644 index 0000000..d8abea1 --- /dev/null +++ b/Ch06/finalpostal/logout.php @@ -0,0 +1,18 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Member's Page

    +

    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +

    +

    Special offers to members only.

    +

    T-Shirts 10.00

    +Polo Shirt +
    +
    + + +
    + +
    + +
    +
    + + + diff --git a/Ch06/finalpostal/mysqli_connect.php b/Ch06/finalpostal/mysqli_connect.php new file mode 100644 index 0000000..87a9d3c --- /dev/null +++ b/Ch06/finalpostal/mysqli_connect.php @@ -0,0 +1,12 @@ + + + + Password Change Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for changing your password

    +On the Home Page, you will now be able to login with your new password. +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/process-change-password.php b/Ch06/finalpostal/process-change-password.php new file mode 100644 index 0000000..13447ae --- /dev/null +++ b/Ch06/finalpostal/process-change-password.php @@ -0,0 +1,126 @@ + + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password = filter_var( $_POST['password'], FILTER_SANITIZE_STRING); +$string_length = strlen($password); +if (empty($password)){ // +$errors[] ='Please enter a valid old password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password)) { // +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ + // Prepare and check new password + $new_password = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); + $verify_password = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); + if (!empty($new_password)) { + if(preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$new_password)) { + if (($new_password != $verify_password) || + ( $password == $new_password )) + { + $errors[] = 'Your new password did not match the confirmed password and/or '; + $errors[] = 'Your old password is the same as your new password.'; + } +} else { + $errors[] = 'Your new password is not in correct format.'; +} + } else { + $errors[] = 'You did not enter a new password.'; + } +} +} + if (empty($errors)) { // If everything's OK. +try { + // Check that the user has entered the right email address/password combination: + $query = "SELECT userid, password FROM users WHERE ( email=? )"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // use prepared statement to insure that only text is inserted + // bind fields to SQL Statement + mysqli_stmt_bind_param($q, 's', $email); + // execute query + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + $row = mysqli_fetch_array($result, MYSQLI_ASSOC); + if ((mysqli_num_rows($result) == 1) + && (password_verify($password, $row['password']))) + { // Found one record + // Change the password in the database... + // Hash password current 60 characters but can increase + $hashed_passcode = password_hash($new_password, PASSWORD_DEFAULT); + // Make the query: + $query = "UPDATE users SET password=? WHERE email=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // use prepared statement to insure that only text is inserted + // bind fields to SQL Statement + mysqli_stmt_bind_param($q, 'ss', $hashed_passcode, $email); + // execute query + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { // one row updated + // Echo a message + header ("location: password-thanks.php"); + exit(); + } else { // If it did not run OK. + // Public message: + $errorstring = "System Error!
    You could not change password due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + // include footer then close program to stop execution + echo '
    + include("footer.php"); +
    '; + exit(); + } + } else { // Invalid email address/password combination. + $errorstring = 'Error!
    '; + $errorstring .= 'The email address and/or password do not match those on file.'; + $errorstring .= " Please try again."; + echo "

    $errorstring

    "; +} } + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + } else { // Report the errors. + //header ("location: register-page.php"); + $errorstring = "Error! The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> + + + + + + + diff --git a/Ch06/finalpostal/process-login.php b/Ch06/finalpostal/process-login.php new file mode 100644 index 0000000..180dedc --- /dev/null +++ b/Ch06/finalpostal/process-login.php @@ -0,0 +1,93 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password = filter_var( $_POST['password'], FILTER_SANITIZE_STRING); +$string_length = strlen($password); +if (empty($password)){ +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} +} + if (empty($errors)) { // If everything's OK. #1 +// Retrieve the user_id, psword, first_name and user_level for that +// email/password combination + $query = "SELECT userid, password, first_name, user_level FROM users "; + $query .= "WHERE paid='Yes' AND email=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $email); + + // execute query + + mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); +if (mysqli_num_rows($result) == 1) { +//if one database row (record) matches the input:- +// Start the session, fetch the record and insert the +// values in an array +if (password_verify($password, $row[1])) { //#2 +session_start(); +// Ensure that the user level is an integer. +$_SESSION['user_level'] = (int) $row[3]; +// Use a ternary operation to set the URL #3 +$url = ($_SESSION['user_level'] === 1) ? 'admin-page.php' : + 'members-page.php'; +header('Location: ' . $url); +// Make the browser load either the members or the admin page +} else { // No password match was made. +$errors[] = 'E-mail/Password entered does not match our records. '; +$errors[] = 'Perhaps your fee has not yet been processed from '; +$errors[] = ' PayPal or the credit card.'; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} else { // No e-mail match was made. +$errors[] = 'E-mail/Password entered does not match our records. '; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} +if (!empty($errors)) { + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (!empty($errors)) IF. +mysqli_stmt_free_result($q); +mysqli_stmt_close($q); +} + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +} // no else to allow user to enter values +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process-register-page.php b/Ch06/finalpostal/process-register-page.php new file mode 100644 index 0000000..f3a6c15 --- /dev/null +++ b/Ch06/finalpostal/process-register-page.php @@ -0,0 +1,195 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password1trim = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); +$string_length = strlen($password1trim); +if (empty($password1trim)){ // #7 +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password1trim)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ +$password2trim = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); +if($password1trim === $password2trim) { // #9 +$password = $password1trim; +}else{ +$errors[] = 'Your two password do not match.'; +$errors[] = 'Please try again'; +} +} +} +//Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the secret present? If it is, sanitize it +$secret = filter_var( $_POST['secret'], FILTER_SANITIZE_STRING); +if ((!empty($secret)) && (preg_match('/[a-z\.\s\,\-]/i', $secret)) && + (strlen($secret) <= 30)) { + //Sanitize the trimmed city + $secrettrim = $secret; + }else{ + $errors[] = 'Missing city. Only alphabetic, period, comma, dash and space. Max 30.'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } +//Is the class present? If it is, sanitize it +$class = filter_var( $_POST['level'], FILTER_SANITIZE_STRING); +if ((!empty($class)) && (strlen($class) <= 3)) { + //Sanitize the trimmed phone number + $classtrim = (filter_var($class, FILTER_SANITIZE_NUMBER_INT)); + }else{ + $errors[] = 'Missing Level Selection.'; + } +if (empty($errors)) { // If everything's OK. +// If no problems encountered, register user in the database +//Determine whether the email address has already been registered +$query = "SELECT userid FROM users WHERE email = ? "; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +mysqli_stmt_bind_param($q,'s', $emailtrim); +mysqli_stmt_execute($q); +$result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0){//The email address has not been registered +//already therefore register the user in the users table + //-------------Valid Entries - Save to database ----- + //Start of the SUCCESSFUL SECTION. i.e all the required fields were filled out + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + // Register the user in the database... + + $query = "INSERT INTO users (userid, title, first_name, last_name, email, password, class, "; + $query .= "address1, address2, city, state_country, zcode_pcode, phone, secret, registration_date) "; + $query .= "VALUES "; + $query .= "(' ',?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())"; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'sssssssssssss', + $titletrim, $first_nametrim, $last_nametrim, $emailtrim, $hashed_password, $classtrim, $address1trim, + $address2trim, $citytrim, $state_countrytrim, $zcode_pcodetrim, $phonetrim, $secrettrim); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + header ("location: register-thanks.php?class=" . $classtrim); + } else { + // echo 'Invalid query:' . $dbcon->error; + $errorstring = "System is busy, please try later"; + echo "

    $errorstring

    "; + } + }else{//The email address is already registered + $errorstring = 'The email address is already registered.'; + echo "

    $errorstring

    "; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +$errorstring = 'Error! The following error(s) occurred: '; +foreach ($errors as $msg) { // Print each error. +$errorstring .= " - $msg
    \n"; + } +$errorstring .= 'Please try again.'; +echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process_admin_view_users.php b/Ch06/finalpostal/process_admin_view_users.php new file mode 100644 index 0000000..5e61925 --- /dev/null +++ b/Ch06/finalpostal/process_admin_view_users.php @@ -0,0 +1,129 @@ + $pagerows){ //if the number of records will fill more than one page +//Calculate the number of pages and round the result up to the nearest integer +$pages = ceil ($records/$pagerows); // +}else{ +$pages = 1; +} +}//page check finished +//Declare which record to start with +if ((isset($_GET['s'])) &&( is_numeric($_GET['s']))) +{ +$start = htmlspecialchars($_GET['s'], ENT_QUOTES); +// make sure it is not executable XSS +}else{ +$start = 0; +} +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users ORDER BY registration_date ASC"; +$query .=" LIMIT ?, ?"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind $id to SQL Statement +mysqli_stmt_bind_param($q, "ii", $start, $pagerows); + +// execute query + +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran OK (records were returned), display the records. +// Table header. #2 +echo ' + + + + + + + +'; +// Fetch and print all the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of else ($result) +// Now display the total number of records/members. +$q = "SELECT COUNT(userid) FROM users"; +$result = mysqli_query ($dbcon, $q); +$row = mysqli_fetch_array ($result, MYSQLI_NUM); +$members = htmlspecialchars($row[0], ENT_QUOTES); +mysqli_close($dbcon); // Close the database connection. +$echostring = "

    Total membership: $members

    "; +$echostring .= "

    "; +if ($pages > 1) {// +//What number is the current page? +$current_page = ($start/$pagerows) + 1; +//If the page is not the first page then create a Previous link +if ($current_page != 1) { +$echostring .= 'Previous '; +} +//Create a Next link +if ($current_page != $pages) { +$echostring .= ' Next '; +} +$echostring .= '

    '; +echo $echostring; +} +//} +//mysqli_close($dbcon); // Close the database connection. +} //end of try +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process_delete_record.php b/Ch06/finalpostal/process_delete_record.php new file mode 100644 index 0000000..ab86e19 --- /dev/null +++ b/Ch06/finalpostal/process_delete_record.php @@ -0,0 +1,95 @@ +The record has been deleted.'; + } else { // If the query did not run OK display public message + echo '

    The record could not be deleted.'; + echo '
    Either it does not exist or due to a system error.

    '; + // echo '

    ' . mysqli_error($dbcon ) . '
    Query: ' . $q . '

    '; + // Debugging message. When live comment out because this displays sql + } + } else { // User did not confirm deletion. + echo '

    The user has NOT been deleted as you requested

    '; + } +} else { // Show the form. #3 + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT CONCAT(first_name, ' ', last_name) FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $id); + + // execute query + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); // get user info + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + + // Display the record being deleted: + $user = htmlspecialchars($row[0], ENT_QUOTES); +?> +

    + Are you sure you want to permanently delete ?

    +
    +
    + +
    + + - + +
    +
    +
    +This page has been accessed in error.

    '; + echo '

     

    '; + } +} // End of the main submission conditional. +mysqli_stmt_close($q); +mysqli_close($dbcon ); +} +catch(Exception $e) +{ + print "The system is busy. Please try again."; + //print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is currently busy. Please try again soon."; + //print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process_edit_address.php b/Ch06/finalpostal/process_edit_address.php new file mode 100644 index 0000000..63dc607 --- /dev/null +++ b/Ch06/finalpostal/process_edit_address.php @@ -0,0 +1,300 @@ +This page has been accessed in error.

    '; + include ('footer.php'); + exit(); +} +require ('mysqli_connect.php'); +// Has the form been submitted? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); + // Look for the first name: +//Is the title present? If it is, sanitize it + $title = filter_var( $_POST['title'], FILTER_SANITIZE_STRING); + if ((!empty($title)) && (preg_match('/[a-z\.\s]/i',$title)) && + (strlen($title) <= 12)) { + //Sanitize the trimmed title + $titletrim = $title; + }else{ + $titletrim = NULL; // Title is optional + } +// Trim the first name + $first_name = filter_var( $_POST['first_name'], FILTER_SANITIZE_STRING); +if ((!empty($first_name)) && (preg_match('/[a-z\s]/i',$first_name)) && + (strlen($first_name) <= 30)) { + //Sanitize the trimmed first name + $first_nametrim = $first_name; + }else{ + $errors[] = 'First name missing or not alphabetic and space characters. Max 30'; + } + //Is the last name present? If it is, sanitize it + $last_name = filter_var( $_POST['last_name'], FILTER_SANITIZE_STRING); +if ((!empty($last_name)) && (preg_match('/[a-z\-\s\']/i',$last_name)) && + (strlen($last_name) <= 40)) { + //Sanitize the trimmed last name + $last_nametrim = $last_name; + }else{ + $errors[] = 'Last name missing or not alphabetic, dash, quote or space. Max 30.'; + } + //Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } + if (empty($errors)) { // If everything's OK. #2 + $query = 'UPDATE users SET title=?, first_name=?, last_name=?, address1=?,'; + $query .= ' address2=?, city=?, state_country=?, zcode_pcode=?,'; + $query .= ' phone=?'; + $query .= ' WHERE userid=? LIMIT 1'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'ssssssssss', $titletrim, $first_nametrim, $last_nametrim, + $address1trim, $address2trim, $citytrim, $state_countrytrim, + $zcode_pcodetrim, $phonetrim, $id); + // execute query + + mysqli_stmt_execute($q); + + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited.

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited due to a system error.'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } else { // Display the errors. + echo '

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Echo each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.

    '; + } // End of if (empty($errors))section. +} // End of the conditionals +// Select the user's information to display in textboxes: #3 + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT * FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + + $row = mysqli_fetch_array($result, MYSQLI_ASSOC); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + + // Create the form: +?> +

    Edit User

    +

    Items marked with an asterisk * are required

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +This page has been accessed in error.

    '; +} +mysqli_stmt_free_result($q); +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy. Please try later"; + //print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is currently busy. Please try again later"; + //print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process_edit_record.php b/Ch06/finalpostal/process_edit_record.php new file mode 100644 index 0000000..ab7dd33 --- /dev/null +++ b/Ch06/finalpostal/process_edit_record.php @@ -0,0 +1,235 @@ +This page has been accessed in error.

    '; + include ('footer.php'); + exit(); +} + +require ('./mysqli_connect.php'); +// Has the form been submitted? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); +// Trim the first name + $first_name = filter_var( $_POST['first_name'], FILTER_SANITIZE_STRING); +if ((!empty($first_name)) && (preg_match('/[a-z\s]/i',$first_name)) && + (strlen($first_name) <= 30)) { + //Sanitize the trimmed first name + $first_nametrim = $first_name; + }else{ + $errors[] = 'First name missing or not alphabetic and space characters. Max 30'; + } + //Is the last name present? If it is, sanitize it + $last_name = filter_var( $_POST['last_name'], FILTER_SANITIZE_STRING); +if ((!empty($last_name)) && (preg_match('/[a-z\-\s\']/i',$last_name)) && + (strlen($last_name) <= 40)) { + //Sanitize the trimmed last name + $last_nametrim = $last_name; + }else{ + $errors[] = 'Last name missing or not alphabetic, dash, quote or space. Max 30.'; + } +// Check that an email address has been entered + $emailtrim = filter_var( $_POST['email'], FILTER_SANITIZE_EMAIL); + if ((empty($emailtrim)) || (!filter_var($emailtrim, FILTER_VALIDATE_EMAIL)) + || (strlen($emailtrim > 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +//Is the class present? If it is, sanitize it +$class = filter_var( $_POST['level'], FILTER_SANITIZE_STRING); +if ((!empty($class)) && (strlen($class) <= 3)) { + //Sanitize the trimmed phone number + $classtrim = (filter_var($class, FILTER_SANITIZE_NUMBER_INT)); + }else{ + $errors[] = 'Missing Level Selection.'; + } + // Look for the Paid Status: + $paid = filter_var( $_POST['paid'], FILTER_SANITIZE_STRING); + if (empty($paid)) { + $errors[] = 'You forgot to enter the paid status.'; + } + if (!(($paid == "No") || ($paid == "Yes"))) { + $errors[] = "Paid must be No or Yes."; + } + if (empty($errors)) { // If everything's OK. + $q = mysqli_stmt_init($dbcon); + $query = 'SELECT userid FROM users WHERE email=? AND userid !=?'; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'si', $email, $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + + if (mysqli_num_rows($result) == 0) { // e-mail does not exist in another record + $query = 'UPDATE users SET first_name=?, last_name=?, email=?,'; + $query .= ' class=?, paid=?'; + $query .= ' WHERE userid=? LIMIT 1'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'sssssi', $first_name, $last_name, $email, $class, $paid, $id); + // execute query + + mysqli_stmt_execute($q); + + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited.

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited. Did you change anything?'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } else { // Already registered. + echo '

    The email address has already been registered.

    '; + } + } else { // Display the errors. + echo '

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Echo each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.

    '; + } // End of if (empty($errors))section. +} // End of the conditionals +// Select the user's information to display in textboxes: #3 + + $q = mysqli_stmt_init($dbcon); + $query = + "SELECT first_name, last_name, email, class, paid FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + + $row1 = mysqli_fetch_array($result, MYSQLI_ASSOC); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + + // Create the form: +?> +

    Edit a Record

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +This page has been accessed in error.

    '; +} +mysqli_stmt_free_result($q); +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy. Please try later"; + //print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is currently busy. Please try again later"; + //print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process_temp_view_found_record.php b/Ch06/finalpostal/process_temp_view_found_record.php new file mode 100644 index 0000000..cd08dfa --- /dev/null +++ b/Ch06/finalpostal/process_temp_view_found_record.php @@ -0,0 +1,70 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; + +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users WHERE "; +$query .= "last_name='Smith' AND first_name='James' "; +$query .="ORDER BY registration_date ASC "; +// Perpared statement not needed because string is hard coded +$result = mysqli_query ($dbcon, $query); // Run the query. +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "The system is currently busy. Please try later."; +//print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ +print "The system us busy. Please try later."; +//print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process_view_found_addresses.php b/Ch06/finalpostal/process_view_found_addresses.php new file mode 100644 index 0000000..4b42938 --- /dev/null +++ b/Ch06/finalpostal/process_view_found_addresses.php @@ -0,0 +1,96 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; +$first_name = htmlspecialchars($_POST['first_name'], ENT_QUOTES); +$last_name = htmlspecialchars($_POST['last_name'], ENT_QUOTES); +// Since it's a prepared statement below this sanitizing is not needed +// However, to consistantly retrieve than sanitize is a good habit + +$query = "SELECT userid, title, last_name, first_name, "; +$query .= "address1, address2, city, state_country, zcode_pcode, phone "; +$query .= "FROM users WHERE "; +$query .= "last_name=? AND first_name=?"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +mysqli_stmt_bind_param($q, 'ss', $last_name, $first_name); + +// execute query +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + + + + + +'; + +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $title = htmlspecialchars($row['title'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $address1 = htmlspecialchars($row['address1'], ENT_QUOTES); + $address2 = htmlspecialchars($row['address2'], ENT_QUOTES); + $city = htmlspecialchars($row['city'], ENT_QUOTES); + $state_country = htmlspecialchars($row['state_country'], ENT_QUOTES); + $zcode_pcode = htmlspecialchars($row['zcode_pcode'], ENT_QUOTES); + $phone = htmlspecialchars($row['phone'], ENT_QUOTES); + echo ' + + + + + + + + + + + '; + } + echo '
    EditTitleLast NameFirst NameAddress1Address2CityState or CountryZip or Postal CodePhone
    Edit' . $title . '' . $first_name . '' . $last_name . '' . $address1 . '' . $address2 . '' . $city . '' . $state_country . '' . $zcode_pcode . '' . $phone . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "The system is currently busy. Please try later."; +//print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ +print "The system us busy. Please try later."; +//print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch06/finalpostal/process_view_found_record.php b/Ch06/finalpostal/process_view_found_record.php new file mode 100644 index 0000000..a56dc08 --- /dev/null +++ b/Ch06/finalpostal/process_view_found_record.php @@ -0,0 +1,89 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; +$first_name = htmlspecialchars($_POST['first_name'], ENT_QUOTES); +$last_name = htmlspecialchars($_POST['last_name'], ENT_QUOTES); +// Since it's a prepared statement below this sanitizing is not needed +// However, to consistantly retrieve than sanitize is a good habit + +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, class, paid, userid FROM users WHERE "; +$query .= "last_name=? AND first_name=? "; +$query .="ORDER BY registration_date ASC "; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +mysqli_stmt_bind_param($q, 'ss', $last_name, $first_name); + +// execute query +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + $class = htmlspecialchars($row['class'], ENT_QUOTES); + $paid = htmlspecialchars($row['paid'], ENT_QUOTES); + echo ' + + + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate RegisteredClassPaid
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '' . $class . '' . $paid . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "The system is currently busy. Please try later."; +//print "An Exception occurred.Message: " . $e->getMessage(); +}catch(Error $e) +{ +print "The system us busy. Please try later."; +//print "An Error occured. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch06/finalpostal/register-page.php b/Ch06/finalpostal/register-page.php new file mode 100644 index 0000000..9b35e6b --- /dev/null +++ b/Ch06/finalpostal/register-page.php @@ -0,0 +1,245 @@ + + + + Register Page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +

    Items marked with an asterisk * are required

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('includes/info-col-cards.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + echo "
    "; + echo "
    "; + } +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } +catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + ?> + + diff --git a/Ch06/finalpostal/register-password.php b/Ch06/finalpostal/register-password.php new file mode 100644 index 0000000..3425993 --- /dev/null +++ b/Ch06/finalpostal/register-password.php @@ -0,0 +1,116 @@ + + + + Change Password + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch06/finalpostal/register-thanks.php b/Ch06/finalpostal/register-thanks.php new file mode 100644 index 0000000..f936bd1 --- /dev/null +++ b/Ch06/finalpostal/register-thanks.php @@ -0,0 +1,129 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +
    To confirm your registration please verify membership class and pay the membership fee now.
    +
    You can use PayPal or a credit/debit card.
    +

    When you have completed your registration you will be able to login +to the member's only pages.

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +

    +
    + + +
    + +
    + +
    +
    +
    + +
    + + + + + +
    +
    +
    +
    + + +
    + +
    + +
    +getMessage(); + print "The system is busy please try later"; + } +catch(Error $e) +{ + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; +} +?> + + diff --git a/Ch06/finalpostal/register-view-users.php b/Ch06/finalpostal/register-view-users.php new file mode 100644 index 0000000..57aea19 --- /dev/null +++ b/Ch06/finalpostal/register-view-users.php @@ -0,0 +1,93 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } + catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } +?> + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/safer-register-page.php b/Ch06/finalpostal/safer-register-page.php new file mode 100644 index 0000000..76a028c --- /dev/null +++ b/Ch06/finalpostal/safer-register-page.php @@ -0,0 +1,313 @@ + + + + + Register Page + + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +

    Items marked with an asterisk * are required

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('includes/info-col-cards.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + echo "
    "; + echo "
    "; + } +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + } +catch(Error $e) + { + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; + } + ?> + + diff --git a/Ch06/finalpostal/search.php b/Ch06/finalpostal/search.php new file mode 100644 index 0000000..7b97053 --- /dev/null +++ b/Ch06/finalpostal/search.php @@ -0,0 +1,90 @@ + + + + + Search Page + + + + + + +
    + +
    + +
    + +
    + + +
    +

    Search for a record

    +
    Both names are required items
    +
    +
    + +
    + " > +
    +
    +
    + +
    + "> +
    +
    +
    + +
    + +
    +
    +
    +
    + + +'; + include('includes/info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch06/finalpostal/search_addresses.php b/Ch06/finalpostal/search_addresses.php new file mode 100644 index 0000000..919bea6 --- /dev/null +++ b/Ch06/finalpostal/search_addresses.php @@ -0,0 +1,96 @@ + + + + + Search Address Page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +
    +
    Search for an Address or Phone Number
    +
    Both Names are required items
    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('includes/info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch06/finalpostal/temp_view_found_record.php b/Ch06/finalpostal/temp_view_found_record.php new file mode 100644 index 0000000..8a78417 --- /dev/null +++ b/Ch06/finalpostal/temp_view_found_record.php @@ -0,0 +1,55 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are found users

    +

    + +

    + + +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/verify.js b/Ch06/finalpostal/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch06/finalpostal/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch06/finalpostal/view_found_address.php b/Ch06/finalpostal/view_found_address.php new file mode 100644 index 0000000..ef2ae9b --- /dev/null +++ b/Ch06/finalpostal/view_found_address.php @@ -0,0 +1,123 @@ + + + + +View found address page + + + + + +
    +
    + +
    + + +
    +

    Search Address Result

    +If no record is shown, this is because you had an incorrect '; +echo 'or missing entry in the search form.
    '; +echo 'Or the person is not registered with us.'; +echo '
    Please click the Addresses button and try again

    '; +try { +$query = "SELECT user_id, title, lname, fname, addr1, addr2, "; +$query .= "city, state_country, zcode_pcode, phone FROM users "; +$query .= "WHERE fname=? AND lname=?"; +// prepared statement to protect $lname $fname values +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +mysqli_stmt_bind_param($q, 'ss', $fname, $lname); + +// execute query + +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran, display the records. +// Table header. #2 + +echo ' + + + + + + + + + + +'; +// Fetch and display the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + echo ' + + + + + + + + + + + '; + } + echo '
    EditTitleLast NameFirst NameAddrs1Addrs2CityState_Countryzcode_pcodePhone
    Edit' . $row['title'] . '' . $row['fname'] . '' . $row['lname'] . '' . $row['addr1'] . '' . $row['addr2'] . '' . $row['city'] . '' . $row['state_country'] . '' . $row['zcode_pcode'] . '' . $row['phone'] . '
    '; // Close the table. + mysqli_free_result ($result); // Free up the resources. +} else { // If it failed to run +// Public message: + echo '

    The current users could not be retrieved. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($result). Now display the total number of records/members. +$q = "SELECT COUNT(user_id) FROM users"; +$result = @mysqli_query ($dbcon, $q); +$row = @mysqli_fetch_array ($result, MYSQLI_NUM); +$members = $row[0]; +mysqli_close($dbcon); //Close the database connection. +echo "

    Total membership: $members

    "; +} +catch(Exception $e) +{ +print "an Exception occurred. Message:" . $e->getMessage(); +} +catch(Error $e) +{ +print "an Error occurred. Message:" . $e->getMessage(); +} +?> +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/Ch06/finalpostal/view_found_addresses.php b/Ch06/finalpostal/view_found_addresses.php new file mode 100644 index 0000000..611c09e --- /dev/null +++ b/Ch06/finalpostal/view_found_addresses.php @@ -0,0 +1,51 @@ + + + + + View Found Addresses + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are addresses found

    +

    + +

    +
    + +
    + +
    +
    + + diff --git a/Ch06/finalpostal/view_found_record.php b/Ch06/finalpostal/view_found_record.php new file mode 100644 index 0000000..dd02ecf --- /dev/null +++ b/Ch06/finalpostal/view_found_record.php @@ -0,0 +1,51 @@ + + + + + View Found Records + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are users found

    +

    + +

    +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/admin-page.php b/Ch07/migrate/admin-page.php new file mode 100644 index 0000000..88edab9 --- /dev/null +++ b/Ch07/migrate/admin-page.php @@ -0,0 +1,57 @@ + + + + + Admin Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Administration Page

    +

    You have permission to:

    +

    ■Edit and Delete a record

    +

    ■Use the View Members button to page through all the members

    +

    ■Use the Search button to locate a particular member

    +

    ■Use the New Password button to change your password. +

    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/admin-view-users.php b/Ch07/migrate/admin-view-users.php new file mode 100644 index 0000000..c3637ce --- /dev/null +++ b/Ch07/migrate/admin-view-users.php @@ -0,0 +1,138 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + + +Edit +Delete +Last Name +First Name +Email +Date Registered +'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to #5 + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + Edit + Delete + ' . $last_name . ' + ' . $first_name . ' + ' . $email . ' + ' . $registration_date . ' + '; + } + echo ''; // Close the table. + // #7 + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/admin_view_users.php b/Ch07/migrate/admin_view_users.php new file mode 100644 index 0000000..0874f76 --- /dev/null +++ b/Ch07/migrate/admin_view_users.php @@ -0,0 +1,52 @@ + + + + + View Users Page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +

    +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/cap.php b/Ch07/migrate/cap.php new file mode 100644 index 0000000..201053b --- /dev/null +++ b/Ch07/migrate/cap.php @@ -0,0 +1,17 @@ +Are you human? Click recaptcha"; + header( "refresh:1;" ); + } + } + else { echo "

    Are you human? Click recaptcha!

    "; + header( "refresh:1;" ); + } + +?> \ No newline at end of file diff --git a/Ch07/migrate/change-password.php b/Ch07/migrate/change-password.php new file mode 100644 index 0000000..eb049c8 --- /dev/null +++ b/Ch07/migrate/change-password.php @@ -0,0 +1,115 @@ + + + + Change Password + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch07/migrate/delete_record.php b/Ch07/migrate/delete_record.php new file mode 100644 index 0000000..6c63eb2 --- /dev/null +++ b/Ch07/migrate/delete_record.php @@ -0,0 +1,156 @@ + + + + + +Delete a record + + + + + +
    +
    + +
    + + +
    +

    Delete a Record

    +The record has been deleted.'; + } else { // If the query did not run OK display public message + echo '

    The record could not be deleted.'; + echo '
    Either it does not exist or due to a system error.

    '; + // echo '

    ' . mysqli_error($dbcon ) . '
    Query: ' . $q . '

    '; + // Debugging message. When live comment out because this displays sql + } + } else { // User did not confirm deletion. + echo '

    The user has NOT been deleted as you requested

    '; + } +} else { // Show the form. + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT CONCAT(fname, ' ', lname) FROM users WHERE user_id=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $id); + + // execute query + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); // get user info + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + + // Display the record being deleted: + echo "

    Are you sure you want to permanently delete $row[0]?

    "; + // Create the form: + echo '
    + + + + +
    '; + + } else { // Not a valid user ID. + echo '

    This page has been accessed in error.

    '; + echo '

     

    '; + } +} // End of the main submission conditional. +mysqli_stmt_close($q); +mysqli_close($dbcon ); + echo '

     

    '; +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch07/migrate/delete_user.php b/Ch07/migrate/delete_user.php new file mode 100644 index 0000000..9607aef --- /dev/null +++ b/Ch07/migrate/delete_user.php @@ -0,0 +1,53 @@ + + + + + Delete Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/edit_address.php b/Ch07/migrate/edit_address.php new file mode 100644 index 0000000..d4cb1e1 --- /dev/null +++ b/Ch07/migrate/edit_address.php @@ -0,0 +1,53 @@ + + + + + Edit an Address + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/edit_user.php b/Ch07/migrate/edit_user.php new file mode 100644 index 0000000..7610f60 --- /dev/null +++ b/Ch07/migrate/edit_user.php @@ -0,0 +1,53 @@ + + + + + Edit a Record + + + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/edit_your_account.php b/Ch07/migrate/edit_your_account.php new file mode 100644 index 0000000..3001515 --- /dev/null +++ b/Ch07/migrate/edit_your_account.php @@ -0,0 +1,409 @@ + + + + + Edit Your Account Page + + + + + + + + +
    + +
    + +
    + +
    + + + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } + +//Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } + +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } + if (empty($errors)) { // If everything's OK. + // make the query + $q = mysqli_stmt_init($dbcon); + $query = 'SELECT userid FROM users WHERE email=? AND userid !=?'; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'si', $emailtrim, $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0) { // e-mail does not exist in another record + // Make the update query: #5 + + $query = 'UPDATE users SET title=?, first_name=?, last_name=?, email=?, '; + $query .='address1=?, address2=?, city=?, state_country=?, zcode_pcode=?, '; + $query .='phone=?'; + $query .= ' WHERE userid=?'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'ssssssssssi', $titletrim, $first_nametrim, $last_nametrim, + $emailtrim, $address1trim, $address2trim, $citytrim, $state_countrytrim, + $zcode_pcodetrim, $phonetrim, $id); + // execute query + + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + $errorstring = 'The user has been edited.'; + echo "

    $errorstring

    "; + } else { // Echo a message if the query failed. + $errorstring = 'The user could not be edited. Did you change anything?'; + $errorstring .= ' We apologize for any inconvenience.'; // Public message. + echo "

    $errorstring

    "; + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } + } else { // Display the errors. + // ---------------Process User Errors--------------- + // Display the users entry errors + $errorstring = 'Error! The following error(s) occurred: '; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= 'Please try again.'; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} // End of the conditionals +// Select the user's information: #6 + +$query = "SELECT title, first_name, last_name, email, address1, address2, city, state_country, zcode_pcode, phone "; +$query .=" FROM users WHERE userid=?"; +// id was retrieved from database prepared not needed + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + $row = mysqli_fetch_array ($result, MYSQLI_ASSOC); + // Create the form: #7 + + +?> + +
    +

    Edit Your Account Details

    +

    For your own security, please remember to log out!

    + +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +'; + include('includes/info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + echo "
    "; + echo "
    "; + +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } + ?> + + \ No newline at end of file diff --git a/Ch07/migrate/feedback-form.css b/Ch07/migrate/feedback-form.css new file mode 100644 index 0000000..bd6761f --- /dev/null +++ b/Ch07/migrate/feedback-form.css @@ -0,0 +1,8 @@ +#sb, form{ + display: block; + margin-left: auto; + margin-right: auto; + text-align: center; +} +body {margin:0; padding:0; } +.cntr { text-align:center; } diff --git a/Ch07/migrate/feedback-form.php b/Ch07/migrate/feedback-form.php new file mode 100644 index 0000000..a358960 --- /dev/null +++ b/Ch07/migrate/feedback-form.php @@ -0,0 +1,219 @@ + + + + + Feedback Form + + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Edit Your Account Details

    +

    For your own security, please remember to log out!

    +
    Address: 1 The Street, Townsville, AA6 8PF, Tel: 01111 800777
    +
    To email us: Please use this form and click the Send button at the bottom.
    +

    Essential items are marked with an asterisk

    +
    + +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    Would you like us to send a Brochure? (check box):
    +
    +
    + +
    Yes + +
    +
    +
    + +
    Please enter address if you checked the brochure box above
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    Would you like to receive emailed newletters?
    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + +
    + + +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + +
    +
    + +
    + + \ No newline at end of file diff --git a/Ch07/migrate/feedback-handler.php b/Ch07/migrate/feedback-handler.php new file mode 100644 index 0000000..4c94327 --- /dev/null +++ b/Ch07/migrate/feedback-handler.php @@ -0,0 +1,131 @@ + 60))) { + // if email is bad display error page + header( "Location: $emailerrurl" ); + exit ; + } +// Is the phone number present? if so, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize and validate phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; // if not valid or missing do not save + } + //Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Save the 1st address + $address1trim = $address1; + }else{ + $errors = 'yes'; + } +//If the 2nd address is present? If it is, sanitize it +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Save the 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; // If missing or not valid do not save + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Save the city + $citytrim = $city; + }else{ + $errors = 'yes'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Save the state or country + $state_countrytrim = $state_country; + }else{ + $errors = 'yes'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Save the zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors = 'yes'; + } + +$brochure = filter_var( $_POST['brochure'], FILTER_SANITIZE_STRING); +if($brochure != "yes") {$brochure = "no";} // if not yes, then no + +$letter = filter_var( $_POST['letter'], FILTER_SANITIZE_STRING); +if($letter != "yes") {$letter = "no"; } // if not yes, then no + +$comment = filter_var( $_POST['comment'], FILTER_SANITIZE_STRING); +if ((!empty($comment)) && (strlen($comment) <= 480)) { + // remove ability to create link in email + $patterns = array("/http/", "/https/", "/\:/","/\/\//","/www./"); + $commenttrim = preg_replace($patterns," ", $comment); + }else{ // if comment not valid display error page + header( "Location: $errorcommenturl" ); + exit; +} + +if (!empty($errors)) { // if errors display error page +header( "Location: $errorurl" ); +exit ; } +// everything OK send e-mail +$subject = "Message from customer " . $first_nametrim . " " . $last_nametrim; +$messageproper = +"------------------------------------------------------------\n" . +"Name of sender: $first_nametrim $last_nametrim\n" . +"Email of sender: $emailtrim\n" . +"Telephone: $phonetrim\n" . +"brochure?: $brochure\n" . +"Address: $address1trim\n" . +"Address: $address2trim\n" . +"City: $citytrim\n" . +"Postcode: $zcode_pcodetrim\n" . +"Newsletter?:$letter\n" . +"------------------------- MESSAGE -------------------------\n\n" . +$commenttrim . +"\n\n------------------------------------------------------------\n" ; +mail($mailto, $subject, $messageproper, "From: \"$first_nametrim $last_nametrim\" <$emailtrim>" ); +header( "Location: $thankyouurl" ); +exit ; +?> diff --git a/Ch07/migrate/feedback/commenterr.php b/Ch07/migrate/feedback/commenterr.php new file mode 100644 index 0000000..315c783 --- /dev/null +++ b/Ch07/migrate/feedback/commenterr.php @@ -0,0 +1,45 @@ + + + + Email Error Message + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Sorry the format of your comments is not correct.

    +

    Return to the form by clicking the back button on your browser
    and correct your comments.

    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/feedback/emailerr.php b/Ch07/migrate/feedback/emailerr.php new file mode 100644 index 0000000..5e02f0d --- /dev/null +++ b/Ch07/migrate/feedback/emailerr.php @@ -0,0 +1,45 @@ + + + + Email Error Message + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Your email address has an incorrect format.

    +

    Return to the form by clicking the back button on your browser
    and correct your email address.

    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/feedback/error.php b/Ch07/migrate/feedback/error.php new file mode 100644 index 0000000..03e9810 --- /dev/null +++ b/Ch07/migrate/feedback/error.php @@ -0,0 +1,46 @@ + + + + Error Message + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    One or more of the essential items in the form has not been filled in.

    +

    Essential items have an asterisk like this *

    +

    Return to the form by clicking the back button on your browser
    and then fill in the missing items.

    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/feedback/thankyou.php b/Ch07/migrate/feedback/thankyou.php new file mode 100644 index 0000000..26f215f --- /dev/null +++ b/Ch07/migrate/feedback/thankyou.php @@ -0,0 +1,55 @@ + + + + Thank you for your inquiry + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for your inquiry.

    +

    We will email an answer to you shortly.

    +
    + + +
    +
    +
    + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/header-members-account.php b/Ch07/migrate/header-members-account.php new file mode 100644 index 0000000..6585f39 --- /dev/null +++ b/Ch07/migrate/header-members-account.php @@ -0,0 +1,8 @@ +

    This is the Header

    + diff --git a/Ch07/migrate/images/Thumbs.db b/Ch07/migrate/images/Thumbs.db new file mode 100644 index 0000000..04bb756 Binary files /dev/null and b/Ch07/migrate/images/Thumbs.db differ diff --git a/Ch07/migrate/images/fredsemail.jpg b/Ch07/migrate/images/fredsemail.jpg new file mode 100644 index 0000000..42bc75d Binary files /dev/null and b/Ch07/migrate/images/fredsemail.jpg differ diff --git a/Ch07/migrate/images/logo.jpg b/Ch07/migrate/images/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch07/migrate/images/logo.jpg differ diff --git a/Ch07/migrate/images/polo.png b/Ch07/migrate/images/polo.png new file mode 100644 index 0000000..bca2bd2 Binary files /dev/null and b/Ch07/migrate/images/polo.png differ diff --git a/Ch07/migrate/images/tile-pale.jpg b/Ch07/migrate/images/tile-pale.jpg new file mode 100644 index 0000000..ae45d50 Binary files /dev/null and b/Ch07/migrate/images/tile-pale.jpg differ diff --git a/Ch07/migrate/images/vertical_solution_PP.png b/Ch07/migrate/images/vertical_solution_PP.png new file mode 100644 index 0000000..8693bd4 Binary files /dev/null and b/Ch07/migrate/images/vertical_solution_PP.png differ diff --git a/Ch07/migrate/includes/_vti_cnf/footer.php b/Ch07/migrate/includes/_vti_cnf/footer.php new file mode 100644 index 0000000..d722bce --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/footer.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|17 Aug 2017 16:37:50 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|index.php login.php view_found_record.php admin-page.php search_address.php edit_record.php members-page.php page-5.php admin_view_users.php page-3.php page-4.php view_found_address.php search.php delete_record.php page-2.php safer-register-page.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|17 Aug 2017 16:37:50 -0000 +vti_cacheddtm:TX|17 Aug 2017 16:37:50 -0000 +vti_filesize:IR|315 +vti_cachedlinkinfo:VX|H|http://www.colycomputerhelp.co.uk/ H|http://www.littleoceanwaves.com H|http://jigsaw.w3.org/css-validator/ H|http://validator.w3.org/ +vti_cachedsvcrellinks:VX|NHHS|http://www.colycomputerhelp.co.uk/ NHHS|http://www.littleoceanwaves.com NHHS|http://jigsaw.w3.org/css-validator/ NHHS|http://validator.w3.org/ +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/header-admin.php b/Ch07/migrate/includes/_vti_cnf/header-admin.php new file mode 100644 index 0000000..122f566 --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/header-admin.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|19 Dec 2017 20:13:21 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|view_found_record.php admin-page.php search_address.php edit_address.php edit_record.php admin_view_users.php view_found_address.php search.php delete_record.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|19 Dec 2017 20:13:21 -0000 +vti_cacheddtm:TX|19 Dec 2017 20:13:21 -0000 +vti_filesize:IR|357 +vti_cachedlinkinfo:VX|H|logout.php H|admin_view_users.php H|search.php H|search_address.php H|register-password.php +vti_cachedsvcrellinks:VX|NHUS|includes/logout.php NHUS|includes/admin_view_users.php NHUS|includes/search.php NHUS|includes/search_address.php NHUS|includes/register-password.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/header-members.php b/Ch07/migrate/includes/_vti_cnf/header-members.php new file mode 100644 index 0000000..9c8ffb8 --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/header-members.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|07 Sep 2017 17:40:15 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|members-page.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|07 Sep 2017 17:40:15 -0000 +vti_cacheddtm:TX|07 Sep 2017 17:40:15 -0000 +vti_filesize:IR|202 +vti_cachedlinkinfo:VX|H|logout.php H|register-password.php +vti_cachedsvcrellinks:VX|NHUS|includes/logout.php NHUS|includes/register-password.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/header-thanks.php b/Ch07/migrate/includes/_vti_cnf/header-thanks.php new file mode 100644 index 0000000..6d9334e --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/header-thanks.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|06 Dec 2012 20:36:08 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|register-thanks.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|06 Dec 2012 20:36:08 -0000 +vti_cacheddtm:TX|06 Dec 2012 20:36:08 -0000 +vti_filesize:IR|167 +vti_cachedlinkinfo:VX|H|index.php +vti_cachedsvcrellinks:VX|NHUS|includes/index.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/header.php b/Ch07/migrate/includes/_vti_cnf/header.php new file mode 100644 index 0000000..93fdbed --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/header.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|26 Dec 2017 18:19:35 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|index.php page-5.php page-3.php page-4.php page-2.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|26 Dec 2017 18:19:35 -0000 +vti_cacheddtm:TX|26 Dec 2017 18:19:35 -0000 +vti_filesize:IR|199 +vti_cachedlinkinfo:VX|H|login.php H|safer-register-page.php +vti_cachedsvcrellinks:VX|NHUS|includes/login.php NHUS|includes/safer-register-page.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/info-col-cards.php b/Ch07/migrate/includes/_vti_cnf/info-col-cards.php new file mode 100644 index 0000000..b802ce2 --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/info-col-cards.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|28 Feb 2013 20:36:56 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|register-thanks.php admin-page.php members-page.php safer-register-page.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|28 Feb 2013 20:36:56 -0000 +vti_cacheddtm:TX|28 Feb 2013 20:36:56 -0000 +vti_filesize:IR|380 +vti_cachedlinkinfo:VX|S|images/vertical_solution_PP.png +vti_cachedsvcrellinks:VX|NSUS|includes/images/vertical_solution_PP.png +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/info-col.php b/Ch07/migrate/includes/_vti_cnf/info-col.php new file mode 100644 index 0000000..5b90dcd --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/info-col.php @@ -0,0 +1,14 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|07 Dec 2017 12:14:16 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|index.php login.php view_found_record.php search_address.php edit_address.php edit_record.php page-5.php admin_view_users.php view_found_address.php page-3.php page-4.php search.php delete_record.php page-2.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|07 Dec 2017 12:14:16 -0000 +vti_cacheddtm:TX|07 Dec 2017 12:14:16 -0000 +vti_filesize:IR|128 +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/login-header.php b/Ch07/migrate/includes/_vti_cnf/login-header.php new file mode 100644 index 0000000..c7bcfc6 --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/login-header.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|20 Aug 2017 15:20:59 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|login.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|20 Aug 2017 15:20:59 -0000 +vti_cacheddtm:TX|20 Aug 2017 15:20:59 -0000 +vti_filesize:IR|249 +vti_cachedlinkinfo:VX|H|login.php H|register-page.php H|index.php +vti_cachedsvcrellinks:VX|NHUS|includes/login.php NHUS|includes/register-page.php NHUS|includes/index.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/login_page.inc.php b/Ch07/migrate/includes/_vti_cnf/login_page.inc.php new file mode 100644 index 0000000..47aafce --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/login_page.inc.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|29 Oct 2017 18:16:10 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|login.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|29 Oct 2017 18:16:10 -0000 +vti_cacheddtm:TX|29 Oct 2017 18:16:10 -0000 +vti_filesize:IR|668 +vti_cachedlinkinfo:VX|A|login.php +vti_cachedsvcrellinks:VX|NAUS|includes/login.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/nav.php b/Ch07/migrate/includes/_vti_cnf/nav.php new file mode 100644 index 0000000..c315156 --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/nav.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|17 Aug 2017 16:24:57 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|login.php view_found_record.php register-thanks.php index.php admin-page.php search_address.php edit_address.php edit_record.php members-page.php page-5.php admin_view_users.php view_found_address.php page-3.php page-4.php search.php delete_record.php page-2.php safer-register-page.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|17 Aug 2017 16:24:57 -0000 +vti_cacheddtm:TX|17 Aug 2017 16:24:57 -0000 +vti_filesize:IR|387 +vti_cachedlinkinfo:VX|H|page-2.php H|page-3.php H|page-4.php H|page-5.php H|index.php +vti_cachedsvcrellinks:VX|NHUS|includes/page-2.php NHUS|includes/page-3.php NHUS|includes/page-4.php NHUS|includes/page-5.php NHUS|includes/index.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/_vti_cnf/password-header.php b/Ch07/migrate/includes/_vti_cnf/password-header.php new file mode 100644 index 0000000..5cb747e --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/password-header.php @@ -0,0 +1,16 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|26 Sep 2017 17:12:27 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|26 Sep 2017 17:12:27 -0000 +vti_cacheddtm:TX|26 Sep 2017 17:12:27 -0000 +vti_filesize:IR|202 +vti_cachedlinkinfo:VX|H|register-password.php H|index.php +vti_cachedsvcrellinks:VX|NHUS|includes/register-password.php NHUS|includes/index.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 +vti_backlinkinfo:VX| diff --git a/Ch07/migrate/includes/_vti_cnf/register-header.php b/Ch07/migrate/includes/_vti_cnf/register-header.php new file mode 100644 index 0000000..3aa2834 --- /dev/null +++ b/Ch07/migrate/includes/_vti_cnf/register-header.php @@ -0,0 +1,17 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|31 Dec 2017 17:55:46 -0000 +vti_extenderversion:SR|12.0.0.0 +vti_backlinkinfo:VX|safer-register-page.php +vti_author:SR|USERX-893NME34B\\Janice +vti_modifiedby:SR|USERX-893NME34B\\Janice +vti_timecreated:TR|22 Nov 2017 11:42:03 -0000 +vti_nexttolasttimemodified:TW|31 Dec 2017 17:50:34 -0000 +vti_cacheddtm:TX|31 Dec 2017 17:55:46 -0000 +vti_filesize:IR|145 +vti_cachedlinkinfo:VX|H|safer-register-page.php +vti_cachedsvcrellinks:VX|NHUS|includes/safer-register-page.php +vti_cachedneedsrewrite:BR|false +vti_cachedhasbots:BR|false +vti_cachedhastheme:BR|false +vti_cachedhasborder:BR|false +vti_charset:SR|utf-8 diff --git a/Ch07/migrate/includes/footer.php b/Ch07/migrate/includes/footer.php new file mode 100644 index 0000000..4ccb7e8 --- /dev/null +++ b/Ch07/migrate/includes/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2018 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch07/migrate/includes/header-admin.php b/Ch07/migrate/includes/header-admin.php new file mode 100644 index 0000000..50c305b --- /dev/null +++ b/Ch07/migrate/includes/header-admin.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch07/migrate/includes/header-members-account.php b/Ch07/migrate/includes/header-members-account.php new file mode 100644 index 0000000..6585f39 --- /dev/null +++ b/Ch07/migrate/includes/header-members-account.php @@ -0,0 +1,8 @@ +

    This is the Header

    + diff --git a/Ch07/migrate/includes/header-members.php b/Ch07/migrate/includes/header-members.php new file mode 100644 index 0000000..3bf6406 --- /dev/null +++ b/Ch07/migrate/includes/header-members.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/includes/header-thanks.php b/Ch07/migrate/includes/header-thanks.php new file mode 100644 index 0000000..b0b0b07 --- /dev/null +++ b/Ch07/migrate/includes/header-thanks.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + + diff --git a/Ch07/migrate/includes/header.php b/Ch07/migrate/includes/header.php new file mode 100644 index 0000000..69f9524 --- /dev/null +++ b/Ch07/migrate/includes/header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/includes/header1.php b/Ch07/migrate/includes/header1.php new file mode 100644 index 0000000..11a86b0 --- /dev/null +++ b/Ch07/migrate/includes/header1.php @@ -0,0 +1,73 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/includes/header_members_account.php b/Ch07/migrate/includes/header_members_account.php new file mode 100644 index 0000000..48978e3 --- /dev/null +++ b/Ch07/migrate/includes/header_members_account.php @@ -0,0 +1,13 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch07/migrate/includes/info-col-cards.php b/Ch07/migrate/includes/info-col-cards.php new file mode 100644 index 0000000..fda610e --- /dev/null +++ b/Ch07/migrate/includes/info-col-cards.php @@ -0,0 +1,4 @@ + +

    Payment Methods

    + Pay by PayPal or Credit card + diff --git a/Ch07/migrate/includes/info-col.php b/Ch07/migrate/includes/info-col.php new file mode 100644 index 0000000..1c1ae88 --- /dev/null +++ b/Ch07/migrate/includes/info-col.php @@ -0,0 +1,3 @@ +

    This is the information column

    +

    Information area

    + diff --git a/Ch07/migrate/includes/login-header.php b/Ch07/migrate/includes/login-header.php new file mode 100644 index 0000000..aa7c252 --- /dev/null +++ b/Ch07/migrate/includes/login-header.php @@ -0,0 +1,13 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/includes/login_page.inc.php b/Ch07/migrate/includes/login_page.inc.php new file mode 100644 index 0000000..9ee78ca --- /dev/null +++ b/Ch07/migrate/includes/login_page.inc.php @@ -0,0 +1,14 @@ +

    Login

    +
    +

    +

    + +

    + + Between 8 and 12 characters.

    +

    +

    diff --git a/Ch07/migrate/includes/logo.jpg b/Ch07/migrate/includes/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch07/migrate/includes/logo.jpg differ diff --git a/Ch07/migrate/includes/members-header.php b/Ch07/migrate/includes/members-header.php new file mode 100644 index 0000000..de443b4 --- /dev/null +++ b/Ch07/migrate/includes/members-header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/includes/nav.php b/Ch07/migrate/includes/nav.php new file mode 100644 index 0000000..db873ad --- /dev/null +++ b/Ch07/migrate/includes/nav.php @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/Ch07/migrate/includes/password-header.php b/Ch07/migrate/includes/password-header.php new file mode 100644 index 0000000..e6fc6c8 --- /dev/null +++ b/Ch07/migrate/includes/password-header.php @@ -0,0 +1,12 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/includes/register-header.php b/Ch07/migrate/includes/register-header.php new file mode 100644 index 0000000..b1a43e8 --- /dev/null +++ b/Ch07/migrate/includes/register-header.php @@ -0,0 +1,15 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + diff --git a/Ch07/migrate/includes/register-thanks.php b/Ch07/migrate/includes/register-thanks.php new file mode 100644 index 0000000..fa2c9f7 --- /dev/null +++ b/Ch07/migrate/includes/register-thanks.php @@ -0,0 +1,129 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +
    To confirm your registration please verify membership class and pay the membership fee now.
    +
    You can use PayPal or a credit/debit card.
    +

    When you have completed your registration you will be able to login +to the member's only pages.

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +

    +
    + + +
    + +
    + +
    +
    +
    + +
    + + + + + +
    +
    +
    +
    + + +
    + +
    + +
    +getMessage(); + print "The system is busy please try later"; + } +catch(Error $e) +{ + //print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try again later."; +} +?> + + diff --git a/Ch07/migrate/includes/thanks-header.php b/Ch07/migrate/includes/thanks-header.php new file mode 100644 index 0000000..7bdb175 --- /dev/null +++ b/Ch07/migrate/includes/thanks-header.php @@ -0,0 +1,11 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/includes/thankyou-header.php b/Ch07/migrate/includes/thankyou-header.php new file mode 100644 index 0000000..81dd37e --- /dev/null +++ b/Ch07/migrate/includes/thankyou-header.php @@ -0,0 +1,11 @@ +
    +Logo +
    +
    +

    Header Goes Here

    +
    + \ No newline at end of file diff --git a/Ch07/migrate/index.php b/Ch07/migrate/index.php new file mode 100644 index 0000000..7e9feef --- /dev/null +++ b/Ch07/migrate/index.php @@ -0,0 +1,48 @@ + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Home Page

    +

    The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content. The home page content. The home page content.
    + The home page content. The home page content.
    + The home page content. The home page content. The home page content.

    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/login.php b/Ch07/migrate/login.php new file mode 100644 index 0000000..955c313 --- /dev/null +++ b/Ch07/migrate/login.php @@ -0,0 +1,90 @@ + + + + Login page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Login

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + + +'; + include('includes/info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch07/migrate/logo.jpg b/Ch07/migrate/logo.jpg new file mode 100644 index 0000000..4fe01c8 Binary files /dev/null and b/Ch07/migrate/logo.jpg differ diff --git a/Ch07/migrate/logout.php b/Ch07/migrate/logout.php new file mode 100644 index 0000000..d8abea1 --- /dev/null +++ b/Ch07/migrate/logout.php @@ -0,0 +1,18 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    This is the Member's Page

    +

    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +
    The members page content. The members page content. The members page content. +

    +

    Special offers to members only.

    +

    T-Shirts 10.00

    +Polo Shirt +
    +
    + + +
    + +
    + +
    +
    + + + diff --git a/Ch07/migrate/migrate.sql b/Ch07/migrate/migrate.sql new file mode 100644 index 0000000..a54470e --- /dev/null +++ b/Ch07/migrate/migrate.sql @@ -0,0 +1,120 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 07:04 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `migrate` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prices` +-- + +CREATE TABLE `prices` ( + `oneyeargb` decimal(6,0) UNSIGNED NOT NULL, + `oneyearus` decimal(6,0) UNSIGNED NOT NULL, + `fiveyeargb` decimal(6,0) UNSIGNED NOT NULL, + `fiveyearus` decimal(6,0) UNSIGNED NOT NULL, + `militarygb` decimal(6,0) UNSIGNED NOT NULL, + `militaryus` decimal(6,0) UNSIGNED NOT NULL, + `u21gb` decimal(6,0) UNSIGNED NOT NULL, + `u21us` decimal(6,0) UNSIGNED NOT NULL, + `minpricegb` decimal(6,0) UNSIGNED NOT NULL, + `minpriceus` decimal(6,0) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `prices` +-- + +INSERT INTO `prices` (`oneyeargb`, `oneyearus`, `fiveyeargb`, `fiveyearus`, `militarygb`, `militaryus`, `u21gb`, `u21us`, `minpricegb`, `minpriceus`) VALUES +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `class` char(20) NOT NULL, + `user_level` tinyint(2) UNSIGNED NOT NULL, + `address1` varchar(50) NOT NULL, + `address2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `secret` varchar(30) NOT NULL, + `paid` enum('No','Yes') NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `title`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `class`, `user_level`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `secret`, `paid`) VALUES +(34, 'Mr.', 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$TZRpkkmeP6fIl2hy1z2H6OV6WwL1ZcjHLTdrASs1jJm5N77a5kFie', '2018-06-20 10:08:01', '125', 0, '111 Main St', NULL, 'Key West', 'FL', '33040', NULL, 'Smith', 'Yes'), +(35, NULL, 'Jack', 'Smith', 'jsmith@outcook.com', '$2y$10$i9uYUhvXZqbkPuTWnukM7uLGqo/aksE6TlPCTqVVL4h3NtYmRmdpm', '2018-06-20 10:09:52', '125', 1, '111 Main St', NULL, 'Key West', 'FL', '33040', NULL, 'Smith', 'Yes'), +(36, 'Mr.', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UmWacPiHiECQmJz6VpPS5u2ne5oLPswKyhDIF6PcwhbpV7BcYLtGa', '2018-06-20 10:13:51', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(37, 'Ms.', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$w/O9nBxDkm5j8E3apHVP3u6NH6O7VHUizH2TuZC5.Y4OpDXE2POBy', '2018-06-20 10:15:23', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(38, 'Mr.', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$cEgamDEeI79Ka14BDoDjCeeV4z0xrNpYxNFeGdlJ9OIPqnvJxiVL2', '2018-06-20 10:16:49', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(39, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$WFkNsErvl331HYWPx1I6yOMbXqRGjzJCY.xMYucu.AIOsDpw0dtZ2', '2018-06-20 10:18:51', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(40, 'Mr.', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$RYRudOlD4i9dWjY.jlFpQOmiOEeT9YECQCanqTmsUwzs7RVWa0oPG', '2018-06-20 10:20:13', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(41, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$d6N2TjV82II07r7VSpLmeeYt4DbmU8iUx8C8B/uZ03gAemFDxGDti', '2018-06-20 10:31:08', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(42, 'Mrs', 'Annie', 'Mossity', 'amositty@myisp.org.uk', '$2y$10$tgY2g9J0elkfrQIb7j2Jau4U275a/V08eaYsmQqnuwIOGEbTbYxAe', '2018-06-20 10:32:24', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(43, 'Mr.', 'Percey', 'Veer', 'pveer@myisp.com', '$2y$10$Lh4JbdwseMeV0ozvCxAmd.mLjZdkB6lg4OkhA3IxaEeESvO8ug97.', '2018-06-20 10:33:58', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(44, 'Mr.', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$Ko7pl4a2yNY1SkXFIb6LMu1ROoGvRFjYVMOU0cC6ypNoNZC95/6Xq', '2018-06-20 10:35:50', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(45, 'Mr.', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$RKyMLj.ZvtBFwsOgqKS1.O5aW/tQgDdbcfzKpejiHvPtSMn8GzXQ2', '2018-06-20 10:37:14', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(46, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$BLioPYg2pLPz5yHnmnhqvOCr6QbAuGpg6KIhIPA//j8jTJqbXv8Fa', '2018-06-20 10:39:02', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(47, 'Mr.', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$P/7yQfboAVJvDfC275LuxerpTVaOs6yLhsZEeJ1SBoKX.Y8pCFrA2', '2018-06-20 10:40:33', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch07/migrate/mysqli_connect.php b/Ch07/migrate/mysqli_connect.php new file mode 100644 index 0000000..ebc4124 --- /dev/null +++ b/Ch07/migrate/mysqli_connect.php @@ -0,0 +1,12 @@ + + diff --git a/Ch07/migrate/password-thanks.php b/Ch07/migrate/password-thanks.php new file mode 100644 index 0000000..5ea4b55 --- /dev/null +++ b/Ch07/migrate/password-thanks.php @@ -0,0 +1,45 @@ + + + + Password Change Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for changing your password

    +On the Home Page, you will now be able to login with your new password. +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/process-change-password.php b/Ch07/migrate/process-change-password.php new file mode 100644 index 0000000..8fcbd94 --- /dev/null +++ b/Ch07/migrate/process-change-password.php @@ -0,0 +1,143 @@ + + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password = filter_var( $_POST['password'], FILTER_SANITIZE_STRING); +$string_length = strlen($password); +if (empty($password)){ // +$errors[] ='Please enter a valid old password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password)) { // +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ + // Prepare and check new password + $new_password = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); + $verify_password = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); + if (!empty($new_password)) { + if(preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$new_password)) { + if (($new_password != $verify_password) || + ( $password == $new_password )) + { + $errors[] = 'Your new password did not match the confirmed password and/or '; + $errors[] = 'Your old password is the same as your new password.'; + } +} else { + $errors[] = 'Your new password is not in correct format.'; +} + } else { + $errors[] = 'You did not enter a new password.'; + } +} +} + if (empty($errors)) { // If everything's OK. +try { + // Check that the user has entered the right email address/password combination: + $query = "SELECT userid, password FROM users WHERE ( email=? )"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // use prepared statement to insure that only text is inserted + // bind fields to SQL Statement + mysqli_stmt_bind_param($q, 's', $email); + // execute query + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + $row = mysqli_fetch_array($result, MYSQLI_ASSOC); + if ((mysqli_num_rows($result) == 1) + && (password_verify($password, $row['password']))) + { // Found one record + // Change the password in the database... + // Hash password current 60 characters but can increase + $hashed_passcode = password_hash($new_password, PASSWORD_DEFAULT); + // Make the query: + $query = "UPDATE users SET password=? WHERE email=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // use prepared statement to insure that only text is inserted + // bind fields to SQL Statement + mysqli_stmt_bind_param($q, 'ss', $hashed_passcode, $email); + // execute query + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { // one row updated + // Echo a message + header ("location: password-thanks.php"); + exit(); + } else { // If it did not run OK. + // Public message: + $errorstring = "System Error!
    You could not change password due "; + $errorstring .= "to a system error. We apologize for any inconvenience.

    "; + echo "

    $errorstring

    "; + // Debugging message below do not use in production + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $query . '

    '; + // include footer then close program to stop execution + echo '
    + include("footer.php"); +
    '; + exit(); + } + } else { // Invalid email address/password combination. + $errorstring = 'Error!
    '; + $errorstring .= 'The email address and/or password do not match those on file.'; + $errorstring .= " Please try again."; + echo "

    $errorstring

    "; +} } +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } + } else { // Report the errors. + //header ("location: register-page.php"); + $errorstring = "Error! The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +?> + + + + + + + diff --git a/Ch07/migrate/process-login.php b/Ch07/migrate/process-login.php new file mode 100644 index 0000000..cb346a8 --- /dev/null +++ b/Ch07/migrate/process-login.php @@ -0,0 +1,110 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password = filter_var( $_POST['password'], FILTER_SANITIZE_STRING); +$string_length = strlen($password); +if (empty($password)){ +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} +} + if (empty($errors)) { // If everything's OK. #1 +// Retrieve the user_id, psword, first_name and user_level for that +// email/password combination + $query = "SELECT userid, password, first_name, user_level FROM users "; + $query .= "WHERE paid='Yes' AND email=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $email); + + // execute query + + mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); +if (mysqli_num_rows($result) == 1) { +//if one database row (record) matches the input:- +// Start the session, fetch the record and insert the +// values in an array +if (password_verify($password, $row[1])) { //#2 +session_start(); +// Ensure that the user level is an integer. +$_SESSION['user_id'] = $row[0]; +$_SESSION['user_level'] = (int) $row[3]; +// Use a ternary operation to set the URL #3 +$url = ($_SESSION['user_level'] === 1) ? 'admin-page.php' : + 'members-page.php'; +header('Location: ' . $url); +// Make the browser load either the members or the admin page +} else { // No password match was made. +$errors[] = 'E-mail/Password entered does not match our records. '; +$errors[] = 'Perhaps your fee has not yet been processed from '; +$errors[] = ' PayPal or the credit card.'; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} else { // No e-mail match was made. +$errors[] = 'E-mail/Password entered does not match our records. '; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} +if (!empty($errors)) { + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (!empty($errors)) IF. + +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +} // no else to allow user to enter values +?> \ No newline at end of file diff --git a/Ch07/migrate/process-register-page.php b/Ch07/migrate/process-register-page.php new file mode 100644 index 0000000..78a1a97 --- /dev/null +++ b/Ch07/migrate/process-register-page.php @@ -0,0 +1,213 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password1trim = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); +$string_length = strlen($password1trim); +if (empty($password1trim)){ // #7 +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password1trim)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ +$password2trim = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); +if($password1trim === $password2trim) { // #9 +$password = $password1trim; +}else{ +$errors[] = 'Your two password do not match.'; +$errors[] = 'Please try again'; +} +} +} +//Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the secret present? If it is, sanitize it +$secret = filter_var( $_POST['secret'], FILTER_SANITIZE_STRING); +if ((!empty($secret)) && (preg_match('/[a-z\.\s\,\-]/i', $secret)) && + (strlen($secret) <= 30)) { + //Sanitize the trimmed city + $secrettrim = $secret; + }else{ + $errors[] = 'Missing city. Only alphabetic, period, comma, dash and space. Max 30.'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } +//Is the class present? If it is, sanitize it +$class = filter_var( $_POST['level'], FILTER_SANITIZE_STRING); +if ((!empty($class)) && (strlen($class) <= 3)) { + //Sanitize the trimmed phone number + $classtrim = (filter_var($class, FILTER_SANITIZE_NUMBER_INT)); + }else{ + $errors[] = 'Missing Level Selection.'; + } +if (empty($errors)) { // If everything's OK. +// If no problems encountered, register user in the database +//Determine whether the email address has already been registered +$query = "SELECT userid FROM users WHERE email = ? "; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +mysqli_stmt_bind_param($q,'s', $emailtrim); +mysqli_stmt_execute($q); +$result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0){//The email address has not been registered +//already therefore register the user in the users table + //-------------Valid Entries - Save to database ----- + //Start of the SUCCESSFUL SECTION. i.e all the required fields were filled out + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + // Register the user in the database... + + $query = "INSERT INTO users (userid, title, first_name, last_name, email, password, class, "; + $query .= "address1, address2, city, state_country, zcode_pcode, phone, secret, registration_date) "; + $query .= "VALUES "; + $query .= "(' ',?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())"; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'sssssssssssss', + $titletrim, $first_nametrim, $last_nametrim, $emailtrim, $hashed_password, $classtrim, $address1trim, + $address2trim, $citytrim, $state_countrytrim, $zcode_pcodetrim, $phonetrim, $secrettrim); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + header ("location: register-thanks.php?class=" . $classtrim); + } else { + // echo 'Invalid query:' . $dbcon->error; + $errorstring = "System is busy, please try later"; + echo "

    $errorstring

    "; + } + }else{//The email address is already registered + $errorstring = 'The email address is already registered.'; + echo "

    $errorstring

    "; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +$errorstring = 'Error! The following error(s) occurred: '; +foreach ($errors as $msg) { // Print each error. +$errorstring .= " - $msg
    \n"; + } +$errorstring .= 'Please try again.'; +echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/process_admin_view_users.php b/Ch07/migrate/process_admin_view_users.php new file mode 100644 index 0000000..a139a91 --- /dev/null +++ b/Ch07/migrate/process_admin_view_users.php @@ -0,0 +1,146 @@ + $pagerows){ //if the number of records will fill more than one page +//Calculate the number of pages and round the result up to the nearest integer +$pages = ceil ($records/$pagerows); // +}else{ +$pages = 1; +} +}//page check finished +//Declare which record to start with +if ((isset($_GET['s'])) &&( is_numeric($_GET['s']))) +{ +$start = htmlspecialchars($_GET['s'], ENT_QUOTES); +// make sure it is not executable XSS +}else{ +$start = 0; +} +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users ORDER BY registration_date ASC"; +$query .=" LIMIT ?, ?"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind $id to SQL Statement +mysqli_stmt_bind_param($q, "ii", $start, $pagerows); + +// execute query + +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran OK (records were returned), display the records. +// Table header. #2 +echo ' + + + + + + + +'; +// Fetch and print all the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} +else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of else ($result) +// Now display the total number of records/members. +$q = "SELECT COUNT(userid) FROM users"; +$result = mysqli_query ($dbcon, $q); +$row = mysqli_fetch_array ($result, MYSQLI_NUM); +$members = htmlspecialchars($row[0], ENT_QUOTES); +mysqli_close($dbcon); // Close the database connection. +$echostring = "

    Total membership: $members

    "; +$echostring .= "

    "; +if ($pages > 1) {// +//What number is the current page? +$current_page = ($start/$pagerows) + 1; +//If the page is not the first page then create a Previous link +if ($current_page != 1) { +$echostring .= 'Previous '; +} +//Create a Next link +if ($current_page != $pages) { +$echostring .= ' Next '; +} +$echostring .= '

    '; +echo $echostring; +} +//} +//mysqli_close($dbcon); // Close the database connection. +} //end of try +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/process_delete_record.php b/Ch07/migrate/process_delete_record.php new file mode 100644 index 0000000..e3ec5b8 --- /dev/null +++ b/Ch07/migrate/process_delete_record.php @@ -0,0 +1,113 @@ +The record has been deleted.'; + } else { // If the query did not run OK display public message + echo '

    The record could not be deleted.'; + echo '
    Either it does not exist or due to a system error.

    '; + // echo '

    ' . mysqli_error($dbcon ) . '
    Query: ' . $q . '

    '; + // Debugging message. When live comment out because this displays sql + } + } else { // User did not confirm deletion. + echo '

    The user has NOT been deleted as you requested

    '; + } +} else { // Show the form. #3 + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT CONCAT(first_name, ' ', last_name) FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $id); + + // execute query + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); // get user info + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + + // Display the record being deleted: + $user = htmlspecialchars($row[0], ENT_QUOTES); +?> +

    + Are you sure you want to permanently delete ?

    +
    +
    + +
    + + - + +
    +
    +
    +This page has been accessed in error.

    '; + echo '

     

    '; + } +} // End of the main submission conditional. +mysqli_stmt_close($q); +mysqli_close($dbcon ); +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/process_edit_address.php b/Ch07/migrate/process_edit_address.php new file mode 100644 index 0000000..eb4aa02 --- /dev/null +++ b/Ch07/migrate/process_edit_address.php @@ -0,0 +1,318 @@ +This page has been accessed in error.

    '; + include ('footer.php'); + exit(); +} +require ('mysqli_connect.php'); +// Has the form been submitted? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); + // Look for the first name: +//Is the title present? If it is, sanitize it + $title = filter_var( $_POST['title'], FILTER_SANITIZE_STRING); + if ((!empty($title)) && (preg_match('/[a-z\.\s]/i',$title)) && + (strlen($title) <= 12)) { + //Sanitize the trimmed title + $titletrim = $title; + }else{ + $titletrim = NULL; // Title is optional + } +// Trim the first name + $first_name = filter_var( $_POST['first_name'], FILTER_SANITIZE_STRING); +if ((!empty($first_name)) && (preg_match('/[a-z\s]/i',$first_name)) && + (strlen($first_name) <= 30)) { + //Sanitize the trimmed first name + $first_nametrim = $first_name; + }else{ + $errors[] = 'First name missing or not alphabetic and space characters. Max 30'; + } + //Is the last name present? If it is, sanitize it + $last_name = filter_var( $_POST['last_name'], FILTER_SANITIZE_STRING); +if ((!empty($last_name)) && (preg_match('/[a-z\-\s\']/i',$last_name)) && + (strlen($last_name) <= 40)) { + //Sanitize the trimmed last name + $last_nametrim = $last_name; + }else{ + $errors[] = 'Last name missing or not alphabetic, dash, quote or space. Max 30.'; + } + //Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } + if (empty($errors)) { // If everything's OK. #2 + $query = 'UPDATE users SET title=?, first_name=?, last_name=?, address1=?,'; + $query .= ' address2=?, city=?, state_country=?, zcode_pcode=?,'; + $query .= ' phone=?'; + $query .= ' WHERE userid=? LIMIT 1'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'ssssssssss', $titletrim, $first_nametrim, $last_nametrim, + $address1trim, $address2trim, $citytrim, $state_countrytrim, + $zcode_pcodetrim, $phonetrim, $id); + // execute query + + mysqli_stmt_execute($q); + + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited.

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited due to a system error.'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } else { // Display the errors. + echo '

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Echo each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.

    '; + } // End of if (empty($errors))section. +} // End of the conditionals +// Select the user's information to display in textboxes: #3 + + $q = mysqli_stmt_init($dbcon); + $query = "SELECT * FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + + $row = mysqli_fetch_array($result, MYSQLI_ASSOC); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + + // Create the form: +?> +

    Edit User

    +

    Items marked with an asterisk * are required

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +This page has been accessed in error.

    '; +} +mysqli_stmt_free_result($q); +mysqli_close($dbcon); +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/process_edit_record.php b/Ch07/migrate/process_edit_record.php new file mode 100644 index 0000000..180d9b9 --- /dev/null +++ b/Ch07/migrate/process_edit_record.php @@ -0,0 +1,253 @@ +This page has been accessed in error.

    '; + include ('footer.php'); + exit(); +} + +require ('./mysqli_connect.php'); +// Has the form been submitted? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); +// Trim the first name + $first_name = filter_var( $_POST['first_name'], FILTER_SANITIZE_STRING); +if ((!empty($first_name)) && (preg_match('/[a-z\s]/i',$first_name)) && + (strlen($first_name) <= 30)) { + //Sanitize the trimmed first name + $first_nametrim = $first_name; + }else{ + $errors[] = 'First name missing or not alphabetic and space characters. Max 30'; + } + //Is the last name present? If it is, sanitize it + $last_name = filter_var( $_POST['last_name'], FILTER_SANITIZE_STRING); +if ((!empty($last_name)) && (preg_match('/[a-z\-\s\']/i',$last_name)) && + (strlen($last_name) <= 40)) { + //Sanitize the trimmed last name + $last_nametrim = $last_name; + }else{ + $errors[] = 'Last name missing or not alphabetic, dash, quote or space. Max 30.'; + } +// Check that an email address has been entered + $emailtrim = filter_var( $_POST['email'], FILTER_SANITIZE_EMAIL); + if ((empty($emailtrim)) || (!filter_var($emailtrim, FILTER_VALIDATE_EMAIL)) + || (strlen($emailtrim > 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +//Is the class present? If it is, sanitize it +$class = filter_var( $_POST['level'], FILTER_SANITIZE_STRING); +if ((!empty($class)) && (strlen($class) <= 3)) { + //Sanitize the trimmed phone number + $classtrim = (filter_var($class, FILTER_SANITIZE_NUMBER_INT)); + }else{ + $errors[] = 'Missing Level Selection.'; + } + // Look for the Paid Status: + $paid = filter_var( $_POST['paid'], FILTER_SANITIZE_STRING); + if (empty($paid)) { + $errors[] = 'You forgot to enter the paid status.'; + } + if (!(($paid == "No") || ($paid == "Yes"))) { + $errors[] = "Paid must be No or Yes."; + } + if (empty($errors)) { // If everything's OK. + $q = mysqli_stmt_init($dbcon); + $query = 'SELECT userid FROM users WHERE email=? AND userid !=?'; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'si', $email, $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + + if (mysqli_num_rows($result) == 0) { // e-mail does not exist in another record + $query = 'UPDATE users SET first_name=?, last_name=?, email=?,'; + $query .= ' class=?, paid=?'; + $query .= ' WHERE userid=? LIMIT 1'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'sssssi', $first_name, $last_name, $email, $class, $paid, $id); + // execute query + + mysqli_stmt_execute($q); + + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited.

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited due to a system error.'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } else { // Already registered. + echo '

    The email address has already been registered.

    '; + } + } else { // Display the errors. + echo '

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Echo each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.

    '; + } // End of if (empty($errors))section. +} // End of the conditionals +// Select the user's information to display in textboxes: #3 + + $q = mysqli_stmt_init($dbcon); + $query = + "SELECT first_name, last_name, email, class, paid FROM users WHERE userid=?"; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + + $result = mysqli_stmt_get_result($q); + + $row1 = mysqli_fetch_array($result, MYSQLI_ASSOC); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + + // Create the form: +?> +

    Edit a Record

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +This page has been accessed in error.

    '; +} +mysqli_stmt_free_result($q); +mysqli_close($dbcon); +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/process_edit_your_account.php b/Ch07/migrate/process_edit_your_account.php new file mode 100644 index 0000000..d8fc974 --- /dev/null +++ b/Ch07/migrate/process_edit_your_account.php @@ -0,0 +1,174 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } + +//Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } + +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } + if (empty($errors)) { // If everything's OK. + // make the query + $q = mysqli_stmt_init($dbcon); + $query = 'SELECT userid FROM users WHERE email=? AND userid !=?'; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'si', $emailtrim, $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0) { // e-mail does not exist in another record + // Make the update query: #5 + + $query = 'UPDATE users SET title=?, first_name=?, last_name=?, email=?, '; + $query .='address1=?, address2=?, city=?, state_country=?, zcode_pcode=?, '; + $query .='phone=?'; + $query .= ' WHERE userid=?'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'ssssssssssi', $titletrim, $first_nametrim, $last_nametrim, + $emailtrim, $address1trim, $address2trim, $citytrim, $state_countrytrim, + $zcode_pcodetrim, $phonetrim, $id); + // execute query + + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited!!

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited. Did you change anything?'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } + } else { // Display the errors. + // ---------------Process User Errors--------------- + // Display the users entry errors + $errorstring = 'Error! The following error(s) occurred: '; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= 'Please try again.'; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} // End of the conditionals +// Select the user's information: #6 + +$query = "SELECT title, first_name, last_name, email, address1, address2, city, state_country, zcode_pcode, phone "; +$query .=" FROM users WHERE userid=?"; +// id was retrieved from database prepared not needed + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + $row = mysqli_fetch_array ($result, MYSQLI_ASSOC); + // Create the form: #7 + + +?> \ No newline at end of file diff --git a/Ch07/migrate/process_edit_your_account1.php b/Ch07/migrate/process_edit_your_account1.php new file mode 100644 index 0000000..42b81e4 --- /dev/null +++ b/Ch07/migrate/process_edit_your_account1.php @@ -0,0 +1,173 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } + +//Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } + +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } + if (empty($errors)) { // If everything's OK. + // make the query + $q = mysqli_stmt_init($dbcon); + $query = 'SELECT userid FROM users WHERE email=? AND userid !=?'; + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'si', $emailtrim, $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0) { // e-mail does not exist in another record + // Make the update query: #5 + + $query = 'UPDATE users SET title=?, first_name=?, last_name=?, email=?, '; + $query .='address1=?, address2=?, city=?, state_country=?, zcode_pcode=?, '; + $query .='phone=?'; + $query .= ' WHERE userid=?'; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind values to SQL Statement + + mysqli_stmt_bind_param($q, 'ssssssssssi', $titletrim, $first_nametrim, $last_nametrim, + $emailtrim, $address1trim, $address2trim, $citytrim, $state_countrytrim, + $zcode_pcodetrim, $phonetrim, $id); + // execute query + + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { // Update OK + + // Echo a message if the edit was satisfactory: + echo '

    The user has been edited!!

    '; + } else { // Echo a message if the query failed. + echo '

    The user could not be edited. Did you change anything?'; + echo ' We apologize for any inconvenience.

    '; // Public message. + //echo '

    ' . mysqli_error($dbcon) . '
    Query: ' . $q . '

    '; // Debugging message. + // Message above is only for debug and should not display sql in live mode + } + } + } else { // Display the errors. + // ---------------Process User Errors--------------- + // Display the users entry errors + $errorstring = 'Error! The following error(s) occurred: '; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; + } + $errorstring .= 'Please try again.'; + echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} // End of the conditionals +// Select the user's information: #6 + +$query = "SELECT title, first_name, last_name, email, address1, +address2, city, state_country, zcode_pcode, phone "; +$query .=" FROM users WHERE userid=?"; +// id was retrieved from database prepared not needed + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, 'i', $id); + + // execute query + + mysqli_stmt_execute($q); + $result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 1) { // Valid user ID, display the form. + // Get the user's information: + $row = mysqli_fetch_array ($result, MYSQLI_ASSOC); + // Create the form: #7 +?> \ No newline at end of file diff --git a/Ch07/migrate/process_temp_view_found_record.php b/Ch07/migrate/process_temp_view_found_record.php new file mode 100644 index 0000000..76770f5 --- /dev/null +++ b/Ch07/migrate/process_temp_view_found_record.php @@ -0,0 +1,88 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; + +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, userid FROM users WHERE "; +$query .= "last_name='Smith' AND first_name='James' "; +$query .="ORDER BY registration_date ASC "; +// Perpared statement not needed because string is hard coded +$result = mysqli_query ($dbcon, $query); // Run the query. +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + echo ' + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate Registered
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/process_view_found_addresses.php b/Ch07/migrate/process_view_found_addresses.php new file mode 100644 index 0000000..1d665f0 --- /dev/null +++ b/Ch07/migrate/process_view_found_addresses.php @@ -0,0 +1,114 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; +$first_name = htmlspecialchars($_POST['first_name'], ENT_QUOTES); +$last_name = htmlspecialchars($_POST['last_name'], ENT_QUOTES); +// Since it's a prepared statement below this sanitizing is not needed +// However, to consistantly retrieve than sanitize is a good habit + +$query = "SELECT userid, title, last_name, first_name, "; +$query .= "address1, address2, city, state_country, zcode_pcode, phone "; +$query .= "FROM users WHERE "; +$query .= "last_name=? AND first_name=?"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +mysqli_stmt_bind_param($q, 'ss', $last_name, $first_name); + +// execute query +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + + + + + +'; + +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $title = htmlspecialchars($row['title'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $address1 = htmlspecialchars($row['address1'], ENT_QUOTES); + $address2 = htmlspecialchars($row['address2'], ENT_QUOTES); + $city = htmlspecialchars($row['city'], ENT_QUOTES); + $state_country = htmlspecialchars($row['state_country'], ENT_QUOTES); + $zcode_pcode = htmlspecialchars($row['zcode_pcode'], ENT_QUOTES); + $phone = htmlspecialchars($row['phone'], ENT_QUOTES); + echo ' + + + + + + + + + + + '; + } + echo '
    EditTitleLast NameFirst NameAddress1Address2CityState or CountryZip or Postal CodePhone
    Edit' . $title . '' . $first_name . '' . $last_name . '' . $address1 . '' . $address2 . '' . $city . '' . $state_country . '' . $zcode_pcode . '' . $phone . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/process_view_found_record.php b/Ch07/migrate/process_view_found_record.php new file mode 100644 index 0000000..17bcf49 --- /dev/null +++ b/Ch07/migrate/process_view_found_record.php @@ -0,0 +1,107 @@ +If no record is shown, '; +echo 'this is because you had an incorrect '; +echo ' or missing entry in the search form.'; +echo '
    Click the back button on the browser and try again

    '; +$first_name = htmlspecialchars($_POST['first_name'], ENT_QUOTES); +$last_name = htmlspecialchars($_POST['last_name'], ENT_QUOTES); +// Since it's a prepared statement below this sanitizing is not needed +// However, to consistantly retrieve than sanitize is a good habit + +$query = "SELECT last_name, first_name, email, "; +$query .= "DATE_FORMAT(registration_date, '%M %d, %Y')"; +$query .=" AS regdat, class, paid, userid FROM users WHERE "; +$query .= "last_name=? AND first_name=? "; +$query .="ORDER BY registration_date ASC "; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +mysqli_stmt_bind_param($q, 'ss', $last_name, $first_name); + +// execute query +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +if ($result) { // If it ran, display the records. +// Table header. +echo ' + + + + + + + + + +'; +// Fetch and display the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $user_id = htmlspecialchars($row['userid'], ENT_QUOTES); + $last_name = htmlspecialchars($row['last_name'], ENT_QUOTES); + $first_name = htmlspecialchars($row['first_name'], ENT_QUOTES); + $email = htmlspecialchars($row['email'], ENT_QUOTES); + $registration_date = htmlspecialchars($row['regdat'], ENT_QUOTES); + $class = htmlspecialchars($row['class'], ENT_QUOTES); + $paid = htmlspecialchars($row['paid'], ENT_QUOTES); + echo ' + + + + + + + + + '; + } + echo '
    EditDeleteLast NameFirst NameEmailDate RegisteredClassPaid
    EditDelete' . $last_name . '' . $first_name . '' . $email . '' . $registration_date . '' . $class . '' . $paid . '
    '; // Close the table. + // + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch07/migrate/register-password.php b/Ch07/migrate/register-password.php new file mode 100644 index 0000000..3425993 --- /dev/null +++ b/Ch07/migrate/register-password.php @@ -0,0 +1,116 @@ + + + + Change Password + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Change Password

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + } + else + { + echo ''; + echo '
    '; + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch07/migrate/register-thanks.php b/Ch07/migrate/register-thanks.php new file mode 100644 index 0000000..4a85a50 --- /dev/null +++ b/Ch07/migrate/register-thanks.php @@ -0,0 +1,146 @@ + + + + Register Thanks + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    Thank you for registering

    +
    To confirm your registration please verify membership class and pay the membership fee now.
    +
    You can use PayPal or a credit/debit card.
    +

    When you have completed your registration you will be able to login +to the member's only pages.

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +

    +
    + + +
    + +
    + +
    +
    +
    + +
    + + + + + +
    +
    +
    +
    + + +
    + +
    + +
    +getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> + + diff --git a/Ch07/migrate/register-view-users.php b/Ch07/migrate/register-view-users.php new file mode 100644 index 0000000..337fb50 --- /dev/null +++ b/Ch07/migrate/register-view-users.php @@ -0,0 +1,110 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are the registered users

    +

    + +NameDate Registered'; +// Fetch and print all the records: #3 +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { +echo '' . $row['name'] . '' . $row['regdat'] . ''; } + echo ''; // Close the table so that it is ready for displaying. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Error message: +echo '

    The current users could not be retrieved. We apologize'; +echo ' for any inconvenience.

    '; +// Debug message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +exit; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> + +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/safer-register-page.php b/Ch07/migrate/safer-register-page.php new file mode 100644 index 0000000..53b6442 --- /dev/null +++ b/Ch07/migrate/safer-register-page.php @@ -0,0 +1,330 @@ + + + + + Register Page + + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +

    Register

    +

    Items marked with an asterisk * are required

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('includes/info-col-cards.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + echo "
    "; + echo "
    "; + } +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } + ?> + + diff --git a/Ch07/migrate/search.php b/Ch07/migrate/search.php new file mode 100644 index 0000000..7b97053 --- /dev/null +++ b/Ch07/migrate/search.php @@ -0,0 +1,90 @@ + + + + + Search Page + + + + + + +
    + +
    + +
    + +
    + + +
    +

    Search for a record

    +
    Both names are required items
    +
    +
    + +
    + " > +
    +
    +
    + +
    + "> +
    +
    +
    + +
    + +
    +
    +
    +
    + + +'; + include('includes/info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch07/migrate/search_addresses.php b/Ch07/migrate/search_addresses.php new file mode 100644 index 0000000..a1631ee --- /dev/null +++ b/Ch07/migrate/search_addresses.php @@ -0,0 +1,96 @@ + + + + + Search Address Page + + + + + + + +
    + +
    + +
    + +
    + + + + +
    +
    +
    Search for an Address or Phone Number
    +
    Both Names are required items
    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('includes/info-col.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + ?> +
    +
    + + diff --git a/Ch07/migrate/styles.css b/Ch07/migrate/styles.css new file mode 100644 index 0000000..6242b84 --- /dev/null +++ b/Ch07/migrate/styles.css @@ -0,0 +1,69 @@ +body {text-align:center; background-color:#D7FFEB; color:navy; font-family: "times new roman"; +font-size: 100%; color: navy; margin: auto; +} +h2 { font-size:150%; color:navy; text-align:center; +} +h3 { font-size:110%; color:navy; text-align:center; +} +#container {position:relative; min-width:960px; max-width:1200px; margin:auto; text-align:left; +} +header, #header-members, #header-admin { margin:10 px auto 0 auto; min-width:960px; max-width:1200px; height:175px; background-image: url('images/tile-pale.jpg'); +background-repeat: repeat; padding:0; color:white; +} +h1 {position:relative; top:40px; font-size:350%; color:white; margin:auto 0 auto 20px; width: 600px; +} +#info-col p { + text-align:center; +} +ul { position:absolute; top:160px; left:-40px; color:navy; width:135px; text-align:center; margin:0; +} +nav ul { position:absolute; top:185px; left:-30px; color:navy; width:135px; text-align:center; margin:0; +} +/* set general side button styles */ +li { width:115px; list-style-type :none; margin-bottom: 3px; text-align: center; +} +/* set general anchor styles */ +li a { display: block; width:115px; color: white; font-weight: bold; text-decoration: none +} +/* specify state styles. */ +/* mouseout (default) */ +li a { background: #5B78BE; border: 4px outset #aabaff; +} +/* mouseover */ +li a:hover { display:block; background: #0a4adf; border: 4px outset #8abaff; width:115px; +} +/* onmousedown */ +li a:active { background:#aecbff; border: 4px inset #aecbff; +} +#reg-navigation ul { float:right; + font-size:medium; width:160px; margin:-150px 15px 0 88%; +} +aside { + float:right; width:150px; +} +#midcol {width:90%; margin:auto;} +#mid-left-col { width:48%; float:left; text-align:left; +} +#mid-right-col {width:48%; float:right; text-align:left; +} +#content { margin-left:150px; margin-right:150px; +} +table { width:700px; border:1px navy solid; border-collapse:collapse; margin:auto; +} +th, td { border:1px navy solid; padding:1px 0 1px 4px; text-align:left; +} +/*td { border:1px navy solid; padding:1px 0 1px 4px; text-align:left; +}*/ +form { margin-left:180px; +} +footer { margin:auto; text-align:center; clear:both; +} +p.error { color:red; font-size:105%; font-weight:bold; text-align:center; +} +.label { float:left; width:210px; text-align:right; clear:left; margin-right:5px; +} +#submit { margin-left:215px; text-align:center; +} +span.left { + text-align:left; +} \ No newline at end of file diff --git a/Ch07/migrate/temp_view_found_record.php b/Ch07/migrate/temp_view_found_record.php new file mode 100644 index 0000000..8a78417 --- /dev/null +++ b/Ch07/migrate/temp_view_found_record.php @@ -0,0 +1,55 @@ + + + + + Template for an interactive web page + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are found users

    +

    + +

    + + +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/users.sql b/Ch07/migrate/users.sql new file mode 100644 index 0000000..373fbe1 --- /dev/null +++ b/Ch07/migrate/users.sql @@ -0,0 +1,120 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jun 20, 2018 at 05:02 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `migrate` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prices` +-- + +CREATE TABLE `prices` ( + `oneyeargb` decimal(6,0) UNSIGNED NOT NULL, + `oneyearus` decimal(6,0) UNSIGNED NOT NULL, + `fiveyeargb` decimal(6,0) UNSIGNED NOT NULL, + `fiveyearus` decimal(6,0) UNSIGNED NOT NULL, + `militarygb` decimal(6,0) UNSIGNED NOT NULL, + `militaryus` decimal(6,0) UNSIGNED NOT NULL, + `u21gb` decimal(6,0) UNSIGNED NOT NULL, + `u21us` decimal(6,0) UNSIGNED NOT NULL, + `minpricegb` decimal(6,0) UNSIGNED NOT NULL, + `minpriceus` decimal(6,0) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `prices` +-- + +INSERT INTO `prices` (`oneyeargb`, `oneyearus`, `fiveyeargb`, `fiveyearus`, `militarygb`, `militaryus`, `u21gb`, `u21us`, `minpricegb`, `minpriceus`) VALUES +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `class` char(20) NOT NULL, + `user_level` tinyint(2) UNSIGNED NOT NULL, + `address1` varchar(50) NOT NULL, + `address2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `secret` varchar(30) NOT NULL, + `paid` enum('No','Yes') NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `title`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `class`, `user_level`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `secret`, `paid`) VALUES +(34, NULL, 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$TZRpkkmeP6fIl2hy1z2H6OV6WwL1ZcjHLTdrASs1jJm5N77a5kFie', '2018-06-20 10:08:01', '125', 0, '111 Main St', NULL, 'Key West', 'FL', '33040', NULL, 'Smith', 'Yes'), +(35, NULL, 'Jack', 'Smith', 'jsmith@outcook.com', '$2y$10$i9uYUhvXZqbkPuTWnukM7uLGqo/aksE6TlPCTqVVL4h3NtYmRmdpm', '2018-06-20 10:09:52', '125', 1, '111 Main St', NULL, 'Key West', 'FL', '33040', NULL, 'Smith', 'Yes'), +(36, 'Mr.', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UmWacPiHiECQmJz6VpPS5u2ne5oLPswKyhDIF6PcwhbpV7BcYLtGa', '2018-06-20 10:13:51', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(37, 'Ms.', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$w/O9nBxDkm5j8E3apHVP3u6NH6O7VHUizH2TuZC5.Y4OpDXE2POBy', '2018-06-20 10:15:23', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(38, 'Mr.', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$cEgamDEeI79Ka14BDoDjCeeV4z0xrNpYxNFeGdlJ9OIPqnvJxiVL2', '2018-06-20 10:16:49', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(39, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$WFkNsErvl331HYWPx1I6yOMbXqRGjzJCY.xMYucu.AIOsDpw0dtZ2', '2018-06-20 10:18:51', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(40, 'Mr.', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$RYRudOlD4i9dWjY.jlFpQOmiOEeT9YECQCanqTmsUwzs7RVWa0oPG', '2018-06-20 10:20:13', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(41, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$d6N2TjV82II07r7VSpLmeeYt4DbmU8iUx8C8B/uZ03gAemFDxGDti', '2018-06-20 10:31:08', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(42, 'Mrs', 'Annie', 'Mossity', 'amositty@myisp.org.uk', '$2y$10$tgY2g9J0elkfrQIb7j2Jau4U275a/V08eaYsmQqnuwIOGEbTbYxAe', '2018-06-20 10:32:24', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(43, 'Mr.', 'Percey', 'Veer', 'pveer@myisp.com', '$2y$10$Lh4JbdwseMeV0ozvCxAmd.mLjZdkB6lg4OkhA3IxaEeESvO8ug97.', '2018-06-20 10:33:58', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(44, 'Mr.', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$Ko7pl4a2yNY1SkXFIb6LMu1ROoGvRFjYVMOU0cC6ypNoNZC95/6Xq', '2018-06-20 10:35:50', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(45, 'Mr.', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$RKyMLj.ZvtBFwsOgqKS1.O5aW/tQgDdbcfzKpejiHvPtSMn8GzXQ2', '2018-06-20 10:37:14', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(46, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$BLioPYg2pLPz5yHnmnhqvOCr6QbAuGpg6KIhIPA//j8jTJqbXv8Fa', '2018-06-20 10:39:02', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'), +(47, 'Mr.', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$P/7yQfboAVJvDfC275LuxerpTVaOs6yLhsZEeJ1SBoKX.Y8pCFrA2', '2018-06-20 10:40:33', '125', 0, '2 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 'London', 'Yes'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch07/migrate/verify.js b/Ch07/migrate/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch07/migrate/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch07/migrate/view_found_addresses.php b/Ch07/migrate/view_found_addresses.php new file mode 100644 index 0000000..6732633 --- /dev/null +++ b/Ch07/migrate/view_found_addresses.php @@ -0,0 +1,51 @@ + + + + + View Found Addresses + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are addresses found

    +

    + +

    +
    + +
    + +
    +
    + + diff --git a/Ch07/migrate/view_found_record.php b/Ch07/migrate/view_found_record.php new file mode 100644 index 0000000..dd02ecf --- /dev/null +++ b/Ch07/migrate/view_found_record.php @@ -0,0 +1,51 @@ + + + + + View Found Records + + + + + + +
    + +
    + +
    + +
    + + + +
    +

    These are users found

    +

    + +

    +
    + +
    + +
    +
    + + diff --git a/Ch08/estate/advert.php b/Ch08/estate/advert.php new file mode 100644 index 0000000..0e61355 --- /dev/null +++ b/Ch08/estate/advert.php @@ -0,0 +1,372 @@ + + + + + Add Home Page + + + + + + + + +
    + +
    + +
    + + 15)) { +$errors[] ='You forgot to enter the price.' ; +} +// check type +$type = (filter_var($_POST['type'], FILTER_SANITIZE_STRING)); + if ((empty($_POST['type'])) || ($_POST['type'] == '- Select -')) { + // user could choose - Select - by mistake + $errors[] = 'You forgot to enter the type of house.'; + } else { + if (($type == "Det-bung") || + ($type == "Sem-det-bung") || + ($type == "Det-house") || + ($type == "Semi-det-house")) + { + //OK + } else { + $errors[] = "Invalid type"; + } + } +// Check for brief description +$mini_descriptiontrim = filter_var( $_POST['mini_description'], FILTER_SANITIZE_STRING); +if ((!empty($mini_descriptiontrim)) && (preg_match('/[a-z0-9\.\!\?\s\,\-]/i', $mini_descriptiontrim)) && + (strlen($mini_descriptiontrim) <= 120)) { + $mini_description = $mini_descriptiontrim; + }else{ + $errors[] = 'Missing description. Only numeric, alphabetic, period, comma, dash and space. Max 120.'; + } + // Check for number of bedrooms +$bedrooms = filter_var( $_POST['bedrooms'], FILTER_SANITIZE_NUMBER_INT); + if ((empty($bedrooms)) || ($bedrooms == '- Select -')) { + $errors[] = 'You forgot to enter the number of bedrooms'; + } else { + if (($bedrooms == "1") || + ($bedrooms == "2") || + ($bedrooms == "3") || + ($bedrooms == "4")) + { + // OK + } else { + $errors[] = "Invalid number of bedrooms"; + } + } + // Check if a thumbnail url has been entered + $thumb = filter_var( $_POST['thumb'], FILTER_SANITIZE_URL); + if ((empty($thumb)) || (strlen($thumb > 45))) { + // thumbnail link is optional + $thumb = NULL; + } + // Check if full description has been entered + $full_descriptiontrim = + filter_var( $_POST['full_description'], FILTER_SANITIZE_STRING); + if ((!empty($full_descriptiontrim)) && + (preg_match('/[a-z0-9\.\!\?\s\,\-]/i', $full_descriptiontrim)) && + (strlen($full_descriptiontrim) <= 400)) { + $full_description = $full_descriptiontrim; + }else{ + $errors[] = + 'Missing description. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } + // full picture + $full_picture = filter_var( $_POST['full_picture'], FILTER_SANITIZE_URL); + if ((empty($full_picture)) || (strlen($full_picture) > 45)){ + // optional + $full_picture = NULL; + } + // Check for status of the house +$status = filter_var( $_POST['status'], FILTER_SANITIZE_STRING); + if ((empty($status)) || ($status == '- Select -')) { + $errors[] = 'You forgot to select a status'; + } else { + if (($status == "Available") || + ($status == "Under offer") || + ($status == "Withdrawn") || + ($status == "Sold")) + { + // OK + } else { + $errors[] = "Invalid status"; + } + } +if (empty($errors)) { // If everything's OK. + // Register the house in the database + // Make the query: + $query = "INSERT INTO houses (ref_number, location, price, type, mini_description, bedrooms, "; + $query .= "thumb, status, full_description, full_picture) "; + $query .= " VALUES "; + $query .= "(' ', ?, ?,?,?,?,?,?,?,? )"; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'sssssssss', $location, $price, $type, $mini_description, $bedrooms, + $thumb, $status, $full_description, $full_picture); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { +// Good + header ("location: another.php"); +} else { // If it did not run OK. +// Message: + $errorstring = 'System Error '; + $errorstring .= 'The house could not be added due to a system error. '; + $errorstring .= 'We apologize for any inconvenience.'; +// Debugging message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($r) IF. +mysqli_close($dbcon); // Close the database connection. +exit(); +} else { // Report the errors. + $errorstring = 'Error!'; + $errorstring .= ' The following error(s) occurred:
    '; +foreach ($errors as $msg) { // Print each error. + $errorstring .= " - $msg
    \n"; +} + $errorstring .= 'Please try again.'; + +}// End of if (empty($errors)) IF. +} // try +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +} // End of the main Submit conditional. +?> +
    + +
    + +
    + +
    + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/advert_houses.php b/Ch08/estate/advert_houses.php new file mode 100644 index 0000000..3a2455d --- /dev/null +++ b/Ch08/estate/advert_houses.php @@ -0,0 +1,188 @@ + + + + + Admin View All Houses + + + + + + + + +
    + +
    + +
    +
    + +
    + +
    +

    Houses displayed four at-a-time

    +
    + +
    + $pagerows){ //if the number of records will fill more than one page +//Calculatethe number of pages and round the result up to the nearest integer +$pages = ceil ($records/$pagerows); +}else{ +$pages = 1; +} +}//page check finished. Declare which record to start with +If (isset($_GET['start'])) { +$start = (filter_var($_GET['start'], FILTER_SANITIZE_NUMBER_INT)); +} else { +$start = 0; +} +// Make the query: +$query = "SELECT ref_number, location, thumb, price, mini_description, bedrooms, status "; +$query .= "FROM houses ORDER BY ref_number DESC LIMIT ?, ?"; + + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // use prepared statement to insure that only text is inserted + // bind fields to SQL Statement + mysqli_stmt_bind_param($q, 'ii', $start, $pagerows ); + // execute query + mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); +//$houses = mysqli_num_rows($result); +if ($result) { // If it ran OK, display the records. +// Table header. +echo ' + + + + + + + + +'; +// Fetch and print all the records: +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + // Remove special characters that might already be in table to + // reduce the chance of XSS exploits + $ref_number = htmlspecialchars($row['ref_number'], ENT_QUOTES); + $location = htmlspecialchars($row['location'], ENT_QUOTES); + $thumb = htmlspecialchars($row['thumb'], FILTER_FLAG_NO_ENCODE_QUOTES); + $price = htmlspecialchars($row['price'], ENT_QUOTES); + $mini_description = htmlspecialchars($row['mini_description'], ENT_QUOTES); + $bedrooms = htmlspecialchars($row['bedrooms'], ENT_QUOTES); + $status = htmlspecialchars($row['status'], ENT_QUOTES); + echo ' + + + + + + + + '; + } + echo '
    Ref-NumLocationThumbPriceFeaturesBedroomsStatus
    ' . $ref_number . '' . $location . '' . $price . '' . $mini_description . '' . $bedrooms . '' . $status . '
    '; // Close the table. + mysqli_free_result ($result); // Free up the resources. +} else { // If it did not run OK. +// Message: + $errorstring = '

    The record could not be retrieved. '; + $errorstring .= 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($result). Now display the total number of records/houses +$q = "SELECT COUNT(ref_number) FROM houses"; +$result = mysqli_query ($dbcon, $q); +$row = mysqli_fetch_array ($result, MYSQLI_NUM); +$houses = (filter_var($row[0], FILTER_SANITIZE_NUMBER_INT)); +mysqli_close($dbcon); // Close the database connection. +echo "

    Total found: $houses

    "; +if ($pages > 1) { +echo '
    '; +//What number is the current page? +$current_page = ($start/$pagerows) + 1; +//If the page is not the first page then create a Previous link +if ($current_page != 1) { +echo 'Previous '; +} +//Create a Next link +if ($current_page != $pages) { +echo 'Next '; +} +echo '
    '; +} +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/advert_search.php b/Ch08/estate/advert_search.php new file mode 100644 index 0000000..9eacc62 --- /dev/null +++ b/Ch08/estate/advert_search.php @@ -0,0 +1,82 @@ + + + + + Admin Search Page + + + + + + + + +
    + +
    + +
    + +
    + +
    + +
    +
    + +
    + +
    +

    Search for a record

    +
    Enter the Reference Number
    +
    +
    +
    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/another.php b/Ch08/estate/another.php new file mode 100644 index 0000000..61f05ea --- /dev/null +++ b/Ch08/estate/another.php @@ -0,0 +1,56 @@ + + + + + Add Another Home Page + + + + + + + + +
    + +
    + +
    +
    + +
    + +
    +
    The house was successfully added!!
    +
    Add Another?
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/cap.php b/Ch08/estate/cap.php new file mode 100644 index 0000000..201053b --- /dev/null +++ b/Ch08/estate/cap.php @@ -0,0 +1,17 @@ +Are you human? Click recaptcha"; + header( "refresh:1;" ); + } + } + else { echo "

    Are you human? Click recaptcha!

    "; + header( "refresh:1;" ); + } + +?> \ No newline at end of file diff --git a/Ch08/estate/contact-handler.php b/Ch08/estate/contact-handler.php new file mode 100644 index 0000000..7ee36d2 --- /dev/null +++ b/Ch08/estate/contact-handler.php @@ -0,0 +1,73 @@ + 60))) { + // if email is bad display error page + header( "Location: $emailerrurl" ); + exit ; + } +// Is the phone number present? if so, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize and validate phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; // if not valid or missing do not save + } + //Is the 1st address present? If it is, sanitize it +$ref_number = filter_var( $_POST['ref_number'], FILTER_SANITIZE_STRING); +if ((!empty($ref_number)) && (preg_match('/[0-9]/', $ref_number)) && + (strlen($ref_number) <= 30)) { + //Save the 1st address + $ref_numbertrim = $ref_number; + }else{ + $errors = 'yes'; + } +$comment = filter_var( $_POST['comment'], FILTER_SANITIZE_STRING); +if ((!empty($comment)) && (strlen($comment) <= 320)) { + // remove ability to create link in email + $patterns = array("/http/", "/https/", "/\:/","/\/\//","/www./"); + $commenttrim = preg_replace($patterns," ", $comment); + }else{ // if comment not valid display error page + header( "Location: $errorcommenturl" ); + exit; +} + +if (!empty($errors)) { // if errors display error page +header( "Location: $errorurl" ); +exit ; } +// everything OK send e-mail +$subject = "Message from customer " . $usernametrim; +$messageproper = +"------------------------------------------------------------\n" . +"Name of sender: $usernametrim\n" . +"Email of sender: $useremailtrim\n" . +"Telephone: $phonetrim\n" . +"Ref Number: $ref_numbertrim\n" . +"------------------------- MESSAGE -------------------------\n\n" . +$commenttrim . +"\n\n------------------------------------------------------------\n" ; +mail($mailto, $subject, $messageproper, "From: \"$usernametrim\" <$useremailtrim>" ); +header( "Location: $thankyouurl" ); +exit ; +?> diff --git a/Ch08/estate/contact.php b/Ch08/estate/contact.php new file mode 100644 index 0000000..780342e --- /dev/null +++ b/Ch08/estate/contact.php @@ -0,0 +1,130 @@ + + + + Contact Us Form + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    +
    +
    +

    Contact us to Arrange a Viewing

    +
    Address: 1 The Street, Townsville, AA6 8PF, Tel: 01111 800777
    +
    To contact us: Please use this form and click the Send button at the bottom.
    +
    Essential items are marked with an asterisk
    +
    +
    + +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    To request a viewing please enter the reference number of the house below
    +
    +
    + +
    + " > +
    +
    +
    + +
    + + +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/estatedb.sql b/Ch08/estate/estatedb.sql new file mode 100644 index 0000000..368b367 --- /dev/null +++ b/Ch08/estate/estatedb.sql @@ -0,0 +1,141 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 07:07 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `estatedb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `houses` +-- + +CREATE TABLE `houses` ( + `ref_number` mediumint(6) UNSIGNED NOT NULL, + `location` tinytext CHARACTER SET utf8 NOT NULL, + `price` decimal(9,2) NOT NULL, + `type` tinytext CHARACTER SET utf8 NOT NULL, + `mini_description` varchar(100) CHARACTER SET utf8 NOT NULL, + `bedrooms` tinyint(2) NOT NULL, + `thumb` varchar(45) CHARACTER SET utf8 NOT NULL, + `status` tinytext CHARACTER SET utf8 NOT NULL, + `full_description` varchar(600) CHARACTER SET utf8 NOT NULL, + `full_picture` varchar(45) CHARACTER SET utf8 NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `houses` +-- + +INSERT INTO `houses` (`ref_number`, `location`, `price`, `type`, `mini_description`, `bedrooms`, `thumb`, `status`, `full_description`, `full_picture`) VALUES +(1000, 'South_Devon', '350000.00', 'Det-bung', 'New property in rural situation but close to village shops', 3, 'images/thumbs/house01-191.gif', 'Sold', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1001, 'North_Devon', '320000.00', 'Det-bung', 'Delightful rural location but close to village shops', 3, 'images/thumbs/house01-191.gif', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1002, 'Mid_Devon', '300000.00', 'Det-bung', 'Delightful rural location but close to village shops', 3, 'images/thumbs/house01-191.gif', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1003, 'South_Devon', '400000.00', 'Det-house', 'Located on the outskirts of a thriving town. Stunning rural views.', 4, 'images/thumbs/house10-151.gif', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', 'images/pictures/house10.gif'), +(1004, 'North_Devon', '380000.00', 'Det-house', 'Semi rural location within walking distance of Townsville ', 4, 'images/thumbs/house10-151.gif', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1005, 'Mid_Devon', '360000.00', 'Det-house', 'Located on the edge of the town of Townsville.', 4, 'images/thumbs/house10-151.gif', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1006, 'Mid_Devon', '330000.00', 'Det-house', 'Semi rural with magnificent views of the countryside', 4, 'images/thumbs/house10-151.gif', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1007, 'South_Devon', '390000.00', 'Det-house', 'A town house with rural views. Located close to shops. ', 4, '\"images/thumbs/house12-102.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1008, 'Mid_Devon', '390000.00', 'Det-house', 'New build in rural loaction within walking distance of shops.', 4, '\"images/thumbs/house02-120.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1009, 'South_Devon', '390000.00', 'Det-house', 'A town house with character ', 4, '\"images/thumbs/house06-126.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1010, 'South_Devon', '295000.00', 'Det_house', 'In need of refurbishment', 4, '\"images/thumbs/house06-126.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1011, 'South_Devon', '295000.00', 'Det-house', 'In need of refurbishment', 4, '\"images/thumbs/house06-126.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1012, 'South_Devon', '350000.00', 'Semi-det-house', 'Recently refurbished throughout. Quiet urban location.', 3, '\"images/thumbs/house03-137-semi.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1013, 'South_Devon', '290000.00', 'Semi-det-house', 'Grade 2 Listed. Needs some refurbishment Quiet rural location.', 3, '\"images/thumbs/house09-semi-110.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1014, 'South_Devon', '290000.00', 'Det-house', 'Modern town house in quiet location', 3, '\"images/thumbs/house12-102.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1015, 'North_Devon', '390000.00', 'Det-house', 'Modern town house in quiet location', 3, '\"images/thumbs/house10-151.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1016, 'North_Devon', '290000.00', 'Sem-det-bung', 'Modern bugalow in quiet location', 3, '\"images/thumbs/bung13-semi-thumb.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1017, 'North_Devon', '250000.00', 'Sem-det-bung', 'Modern bungalow in quiet location', 2, '\"images/thumbs/bung13-semi-thumb.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1018, 'North_Devon', '150000.00', 'Det-bung', 'Bungalow with character in rural location. Needs some refurbishment.', 2, '\"images/thumbs/house08.jpg\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1019, 'Mid_Devon', '150000.00', 'Det-bung', 'Bungalow with character in rural location. Needs some refurbishment.', 2, '\"images/thumbs/house08.jpg\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1020, 'South_Devon', '150000.00', 'Det-bung', 'Bungalow with character in rural location. Needs some refurbishment.', 2, '\"images/thumbs/house08.jpg\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1021, 'South_Devon', '290000.00', 'Det-house', 'Beach house. Needs some refurbishment.', 2, '\"images/thumbs/house05-104.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1022, 'Mid_Devon', '270000.00', 'Det-house', 'Rural locstion. House needs some refurbishment.', 3, '\"images/thumbs/house07-153.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1023, 'South_Devon', '280000.00', 'Det-house', 'Rural location. House needs some refurbishment.', 3, '\"images/thumbs/house07-153.gif\"', 'Available', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1024, 'South_Devon', '320000.00', 'Det-house', 'Rubbish', 3, '\"images/thumbs/house06-126.gif\"', 'Withdrawn', '

    A large and superbly presented detached house located in a beautiful \r\n valley in South Devon. Four good size bedrooms, all en-suite. Three generous \r\n reception rooms, luxury kitchen and main bathroom.   
    Double \r\n Garage with radio operated doors. parking space for three cars in \r\n front of the house. Large landscaped rear garden (approximately one \r\n acre) with green house, summer house and hot tub. Neat front garden with rockery.

    ', ''), +(1025, 'South_Devon', '320000.00', 'Det-house', 'Rubbish', 3, '\"images/house06-126.gif\"', 'Withdrawn', '', ''), +(1026, 'Mid_Devon', '270000.00', 'Sem-det-bung', 'Recently built semi-detached bungalow in a pleasant cul-de-sac n and bathroom. Good gardens.', 3, '\"images/bung13-semi-thumb.gif\"', 'Available', '', ''), +(1027, 'North_Devon', '270000.00', 'Sem-det-bung', 'Recently built semi-detached bungalow in a pleasant cul-de-sac n and bathroom. Good gardens.', 3, '\"images/bung13-semi-thumb.gif\"', 'Available', '', ''), +(1028, 'Mid_Devon', '250000.00', 'Sem-det-bung', 'Recently refurbished semi- detached bungalow. Pleasant estate, quiet and tree lined. ', 3, '\"images/bung13-semi-thumb.gif\"', 'Available', '', ''), +(1029, 'Mid_Devon', '270000.00', 'Sem-det-bung', 'Located in a delightful village with post office and general stores. Landscaped rear garden. Rural v', 3, '\"images/bung13-semi-thumb.gif\"', 'Available', '', ''), +(1030, 'Mid_Devon', '270000.00', 'Sem-det-bung', 'Located in a delightful village with post office and general stores. Landscaped rear garden. Rural v', 3, '\"images/bung13-semi-thumb.gif\"', 'Available', '', ''), +(1031, 'North_Devon', '280000.00', 'Det-bung', 'Recently built house in an attractive location with full amenities, including school, general stores', 3, '\"images/house02-120.gif\"', 'Available', '', ''), +(1032, 'North_Devon', '290000.00', 'Semi-det-house', 'Delightful semi- detached house in a pleasant urban location', 2, '\"images/house03-137-semi.gif\"', 'Available', '', ''), +(1033, 'Mid_Devon', '250000.00', 'Semi-det-house', 'Well presented semi-detached house in pleasant surroundings.', 2, '\"images/house03-137-semi.gif\"', 'Available', '', ''); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `password` char(60) NOT NULL, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `user_level` tinyint(2) UNSIGNED NOT NULL, + `email` varchar(50) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `password`, `first_name`, `last_name`, `user_level`, `email`) VALUES +(10, '$2y$10$3YLxPRe/dEmD7VLlUTw/QO8.EUtUz9OB01CMlWH/tBv3.Dz8JiHZa', 'Jack', 'Smith', 1, 'jsmith@outcook.com'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `houses` +-- +ALTER TABLE `houses` + ADD PRIMARY KEY (`ref_number`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `houses` +-- +ALTER TABLE `houses` + MODIFY `ref_number` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1034; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch08/estate/feedback/commenterr.html b/Ch08/estate/feedback/commenterr.html new file mode 100644 index 0000000..b82533a --- /dev/null +++ b/Ch08/estate/feedback/commenterr.html @@ -0,0 +1,14 @@ + + + +Error message. Do not enter URLs + + + + + +Sorry, but website addresses are not allowed

    +

    Please click the Back button on your internet browser
    and then remove any +website addresses from the form.

    + + diff --git a/Ch08/estate/feedback/emailerr.html b/Ch08/estate/feedback/emailerr.html new file mode 100644 index 0000000..4bc304e --- /dev/null +++ b/Ch08/estate/feedback/emailerr.html @@ -0,0 +1,18 @@ + + + +Email error message + + + + + +

     

    +

    Your email address has an incorrect format.

    +

    Please return to the form
    + and then correct your email address.

    +
    + +
    + + \ No newline at end of file diff --git a/Ch08/estate/feedback/error-style.css b/Ch08/estate/feedback/error-style.css new file mode 100644 index 0000000..3f75881 --- /dev/null +++ b/Ch08/estate/feedback/error-style.css @@ -0,0 +1,2 @@ +body { text-align:center; font-size:large; font-weight:bold; } +span {color:red; font-size:x-large; } diff --git a/Ch08/estate/feedback/error.html b/Ch08/estate/feedback/error.html new file mode 100644 index 0000000..ee49060 --- /dev/null +++ b/Ch08/estate/feedback/error.html @@ -0,0 +1,22 @@ + + + +Error message. Missing essentials + + + + + + +

     

    +

     

    +

    One or more of the essential items in the form has not been filled in.

    +

    Essential items have a red asterisk like this *

    +

    Please return to the form
    + and then fill in the missing items

    +
    + +
    + + + \ No newline at end of file diff --git a/Ch08/estate/feedback/feedback-form.css b/Ch08/estate/feedback/feedback-form.css new file mode 100644 index 0000000..bd6761f --- /dev/null +++ b/Ch08/estate/feedback/feedback-form.css @@ -0,0 +1,8 @@ +#sb, form{ + display: block; + margin-left: auto; + margin-right: auto; + text-align: center; +} +body {margin:0; padding:0; } +.cntr { text-align:center; } diff --git a/Ch08/estate/feedback/feedback.css b/Ch08/estate/feedback/feedback.css new file mode 100644 index 0000000..38458ca --- /dev/null +++ b/Ch08/estate/feedback/feedback.css @@ -0,0 +1,12 @@ +/*FEEDBACK.CSS*/ +/*reset browsers for cross-client consistency*/ +body,h2,h3,p {margin:0; padding:0 } +body {text-align:center; background-color:#D7FFEB; color:black; É +font-family: "times new roman"; max-width:100%; min-width:960px; +font-size: medium; color: #000000; margin: auto; width:95%;} +#back-button { margin:20px auto 0 auto; text-align:center; width:200px; height:25px; É +padding:5px; background-color:brown; color:white; font-size:110%; font-weight:bold; } +#back-button a { text-decoration:none; color:white; } +#back-button a:hover { color:red; } +h2 { margin-top:15px; margin-bottom:10px; font-size:130%; font-weight:bold;} +h3 { font-size:110%; font-weight:bold; text-align:center;} diff --git a/Ch08/estate/feedback/thankyou.html b/Ch08/estate/feedback/thankyou.html new file mode 100644 index 0000000..0e6e108 --- /dev/null +++ b/Ch08/estate/feedback/thankyou.html @@ -0,0 +1,19 @@ + + + +Thank you for your enquiry + + + + + +

     

    + +

    +

    Thank you for your inquiry

    +

    We will email an answer to you shortly.

    +
    + + diff --git a/Ch08/estate/footer.php b/Ch08/estate/footer.php new file mode 100644 index 0000000..742b705 --- /dev/null +++ b/Ch08/estate/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2017 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch08/estate/found_houses.php b/Ch08/estate/found_houses.php new file mode 100644 index 0000000..5963270 --- /dev/null +++ b/Ch08/estate/found_houses.php @@ -0,0 +1,191 @@ + + + + + Found Houses Page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    + +

    To arrange a viewing please use the the Contact Us button on the menu and +quote the reference number.

    += (? - 100000)) AND "; +$query .= "type= ? AND bedrooms= ? ORDER BY ref_number ASC "; +} +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); + +// bind values to SQL Statement +//if(($user_level == 1) && (!empty($_POST['ref_number']))) { + if((!empty($_POST['ref_number']))) { + mysqli_stmt_bind_param($q, 's', $ref_number); +} else { +$location = htmlspecialchars($_POST['location'], ENT_QUOTES); +$price = htmlspecialchars($_POST['price'], ENT_QUOTES); +$type = htmlspecialchars($_POST['type'], ENT_QUOTES); +$bedrooms = htmlspecialchars($_POST['bedrooms'], ENT_QUOTES); +mysqli_stmt_bind_param($q, 'sssss', $location, $price, $price, $type, $bedrooms); +} +// execute query +mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +// SELECT is safe execution - read only +if ($result) { // If it ran OK, display the records. +// Table header. +?> + + + + + + + + + + + + + + '; + if ($row['thumb'] == "") + {echo '';} + echo' + + + + + '; + } + echo '
    Ref.LocationThumbPriceFeaturesBedroomsDetailsStatus
    ' . $row['ref_number'] . '' . $row['location'] . '';} + else { echo' ' . $row['price'] . '' . $row['mini_description'] . '' . $row['bedrooms'] . 'Details' . $row['status'] . '
    '; // Close the table. + mysqli_free_result ($result); // Free up the resources. + } else { // If it did not run OK. +// Public message: + echo '

    The current users could not be retrieved.'; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + //Show $q is debug mode only +} // End of if ($result). Now display the total number of records/members. +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> +
    +
    +
    No houses displayed? Sorry we have nothing that matches +your requirements at the moment
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/house_details.php b/Ch08/estate/house_details.php new file mode 100644 index 0000000..b5423d1 --- /dev/null +++ b/Ch08/estate/house_details.php @@ -0,0 +1,131 @@ + + + + + House Details Page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    + +
    Details for House Reference No + +
    +';} +else { echo $row['full_picture']; +echo '">'; +} +?> +
    +
    +

    To arrange a viewing please click the Contact Us button + and quote the reference number +'; +echo '

    £'; +echo $row['price'] . '

    '; +echo $row['full_description']; +?> +

    +The record could not be retrieved. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging error message: +// echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> +
    + +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/images/TIFs/House 2.wmf b/Ch08/estate/images/TIFs/House 2.wmf new file mode 100644 index 0000000..0f6e075 Binary files /dev/null and b/Ch08/estate/images/TIFs/House 2.wmf differ diff --git a/Ch08/estate/images/TIFs/Thumbs.db b/Ch08/estate/images/TIFs/Thumbs.db new file mode 100644 index 0000000..25d8dfe Binary files /dev/null and b/Ch08/estate/images/TIFs/Thumbs.db differ diff --git a/Ch08/estate/images/TIFs/house03-120.tif b/Ch08/estate/images/TIFs/house03-120.tif new file mode 100644 index 0000000..35dafd6 Binary files /dev/null and b/Ch08/estate/images/TIFs/house03-120.tif differ diff --git a/Ch08/estate/images/TIFs/house03-semi-120.gif b/Ch08/estate/images/TIFs/house03-semi-120.gif new file mode 100644 index 0000000..04b5b69 Binary files /dev/null and b/Ch08/estate/images/TIFs/house03-semi-120.gif differ diff --git a/Ch08/estate/images/TIFs/house03-semi.tif b/Ch08/estate/images/TIFs/house03-semi.tif new file mode 100644 index 0000000..a90e98b Binary files /dev/null and b/Ch08/estate/images/TIFs/house03-semi.tif differ diff --git a/Ch08/estate/images/TIFs/house03.tif b/Ch08/estate/images/TIFs/house03.tif new file mode 100644 index 0000000..b1af265 Binary files /dev/null and b/Ch08/estate/images/TIFs/house03.tif differ diff --git a/Ch08/estate/images/TIFs/house05.tif b/Ch08/estate/images/TIFs/house05.tif new file mode 100644 index 0000000..e445894 Binary files /dev/null and b/Ch08/estate/images/TIFs/house05.tif differ diff --git a/Ch08/estate/images/TIFs/house06.tif b/Ch08/estate/images/TIFs/house06.tif new file mode 100644 index 0000000..99b7f6d Binary files /dev/null and b/Ch08/estate/images/TIFs/house06.tif differ diff --git a/Ch08/estate/images/TIFs/house09.tif b/Ch08/estate/images/TIFs/house09.tif new file mode 100644 index 0000000..1a52886 Binary files /dev/null and b/Ch08/estate/images/TIFs/house09.tif differ diff --git a/Ch08/estate/images/TIFs/house10.tif b/Ch08/estate/images/TIFs/house10.tif new file mode 100644 index 0000000..0349a42 Binary files /dev/null and b/Ch08/estate/images/TIFs/house10.tif differ diff --git a/Ch08/estate/images/TIFs/house11.tif b/Ch08/estate/images/TIFs/house11.tif new file mode 100644 index 0000000..0d8006f Binary files /dev/null and b/Ch08/estate/images/TIFs/house11.tif differ diff --git a/Ch08/estate/images/TIFs/house12.tif b/Ch08/estate/images/TIFs/house12.tif new file mode 100644 index 0000000..6f5f067 Binary files /dev/null and b/Ch08/estate/images/TIFs/house12.tif differ diff --git a/Ch08/estate/images/TIFs/house_01.tif b/Ch08/estate/images/TIFs/house_01.tif new file mode 100644 index 0000000..c0a6c24 Binary files /dev/null and b/Ch08/estate/images/TIFs/house_01.tif differ diff --git a/Ch08/estate/images/TIFs/house_08.gif b/Ch08/estate/images/TIFs/house_08.gif new file mode 100644 index 0000000..cb9fbfb Binary files /dev/null and b/Ch08/estate/images/TIFs/house_08.gif differ diff --git a/Ch08/estate/images/Thumbs.db b/Ch08/estate/images/Thumbs.db new file mode 100644 index 0000000..c72458a Binary files /dev/null and b/Ch08/estate/images/Thumbs.db differ diff --git a/Ch08/estate/images/Timberedrow.wmf b/Ch08/estate/images/Timberedrow.wmf new file mode 100644 index 0000000..e6796c3 Binary files /dev/null and b/Ch08/estate/images/Timberedrow.wmf differ diff --git a/Ch08/estate/images/bung13-semi-thumb.gif b/Ch08/estate/images/bung13-semi-thumb.gif new file mode 100644 index 0000000..766ba86 Binary files /dev/null and b/Ch08/estate/images/bung13-semi-thumb.gif differ diff --git a/Ch08/estate/images/bung13-semi.gif b/Ch08/estate/images/bung13-semi.gif new file mode 100644 index 0000000..7114f1a Binary files /dev/null and b/Ch08/estate/images/bung13-semi.gif differ diff --git a/Ch08/estate/images/bung14-semi-thumb.gif b/Ch08/estate/images/bung14-semi-thumb.gif new file mode 100644 index 0000000..f531727 Binary files /dev/null and b/Ch08/estate/images/bung14-semi-thumb.gif differ diff --git a/Ch08/estate/images/bung14-semi.gif b/Ch08/estate/images/bung14-semi.gif new file mode 100644 index 0000000..9b21e35 Binary files /dev/null and b/Ch08/estate/images/bung14-semi.gif differ diff --git a/Ch08/estate/images/devon-map-crop.jpg b/Ch08/estate/images/devon-map-crop.jpg new file mode 100644 index 0000000..5f71cda Binary files /dev/null and b/Ch08/estate/images/devon-map-crop.jpg differ diff --git a/Ch08/estate/images/devon-map.jpg b/Ch08/estate/images/devon-map.jpg new file mode 100644 index 0000000..cd05528 Binary files /dev/null and b/Ch08/estate/images/devon-map.jpg differ diff --git a/Ch08/estate/images/devon-map.tif b/Ch08/estate/images/devon-map.tif new file mode 100644 index 0000000..b789dd9 Binary files /dev/null and b/Ch08/estate/images/devon-map.tif differ diff --git a/Ch08/estate/images/email.png b/Ch08/estate/images/email.png new file mode 100644 index 0000000..c189923 Binary files /dev/null and b/Ch08/estate/images/email.png differ diff --git a/Ch08/estate/images/header3.jpg b/Ch08/estate/images/header3.jpg new file mode 100644 index 0000000..036459a Binary files /dev/null and b/Ch08/estate/images/header3.jpg differ diff --git a/Ch08/estate/images/house01-191.gif b/Ch08/estate/images/house01-191.gif new file mode 100644 index 0000000..f6c8b77 Binary files /dev/null and b/Ch08/estate/images/house01-191.gif differ diff --git a/Ch08/estate/images/house01.gif b/Ch08/estate/images/house01.gif new file mode 100644 index 0000000..5fbda95 Binary files /dev/null and b/Ch08/estate/images/house01.gif differ diff --git a/Ch08/estate/images/house02-120.gif b/Ch08/estate/images/house02-120.gif new file mode 100644 index 0000000..61ae675 Binary files /dev/null and b/Ch08/estate/images/house02-120.gif differ diff --git a/Ch08/estate/images/house02.gif b/Ch08/estate/images/house02.gif new file mode 100644 index 0000000..2266507 Binary files /dev/null and b/Ch08/estate/images/house02.gif differ diff --git a/Ch08/estate/images/house03-137-semi.gif b/Ch08/estate/images/house03-137-semi.gif new file mode 100644 index 0000000..baad192 Binary files /dev/null and b/Ch08/estate/images/house03-137-semi.gif differ diff --git a/Ch08/estate/images/house03-semi.gif b/Ch08/estate/images/house03-semi.gif new file mode 100644 index 0000000..e73fcbe Binary files /dev/null and b/Ch08/estate/images/house03-semi.gif differ diff --git a/Ch08/estate/images/house04-137-semi.gif b/Ch08/estate/images/house04-137-semi.gif new file mode 100644 index 0000000..a22cec4 Binary files /dev/null and b/Ch08/estate/images/house04-137-semi.gif differ diff --git a/Ch08/estate/images/house04-semi.tif b/Ch08/estate/images/house04-semi.tif new file mode 100644 index 0000000..4bcfaad Binary files /dev/null and b/Ch08/estate/images/house04-semi.tif differ diff --git a/Ch08/estate/images/house05-104.gif b/Ch08/estate/images/house05-104.gif new file mode 100644 index 0000000..265f0fc Binary files /dev/null and b/Ch08/estate/images/house05-104.gif differ diff --git a/Ch08/estate/images/house05.gif b/Ch08/estate/images/house05.gif new file mode 100644 index 0000000..a9cd5a6 Binary files /dev/null and b/Ch08/estate/images/house05.gif differ diff --git a/Ch08/estate/images/house06-126.gif b/Ch08/estate/images/house06-126.gif new file mode 100644 index 0000000..bc21e43 Binary files /dev/null and b/Ch08/estate/images/house06-126.gif differ diff --git a/Ch08/estate/images/house06.gif b/Ch08/estate/images/house06.gif new file mode 100644 index 0000000..eee0d35 Binary files /dev/null and b/Ch08/estate/images/house06.gif differ diff --git a/Ch08/estate/images/house07-153.gif b/Ch08/estate/images/house07-153.gif new file mode 100644 index 0000000..1b9453b Binary files /dev/null and b/Ch08/estate/images/house07-153.gif differ diff --git a/Ch08/estate/images/house07.gif b/Ch08/estate/images/house07.gif new file mode 100644 index 0000000..f6a56a2 Binary files /dev/null and b/Ch08/estate/images/house07.gif differ diff --git a/Ch08/estate/images/house07.tif b/Ch08/estate/images/house07.tif new file mode 100644 index 0000000..f01183c Binary files /dev/null and b/Ch08/estate/images/house07.tif differ diff --git a/Ch08/estate/images/house08.jpg b/Ch08/estate/images/house08.jpg new file mode 100644 index 0000000..3ae4faf Binary files /dev/null and b/Ch08/estate/images/house08.jpg differ diff --git a/Ch08/estate/images/house08.tif b/Ch08/estate/images/house08.tif new file mode 100644 index 0000000..cff6af7 Binary files /dev/null and b/Ch08/estate/images/house08.tif differ diff --git a/Ch08/estate/images/house09-semi-110.gif b/Ch08/estate/images/house09-semi-110.gif new file mode 100644 index 0000000..03e176b Binary files /dev/null and b/Ch08/estate/images/house09-semi-110.gif differ diff --git a/Ch08/estate/images/house09-semi.gif b/Ch08/estate/images/house09-semi.gif new file mode 100644 index 0000000..d690a0b Binary files /dev/null and b/Ch08/estate/images/house09-semi.gif differ diff --git a/Ch08/estate/images/house10-151.gif b/Ch08/estate/images/house10-151.gif new file mode 100644 index 0000000..a027584 Binary files /dev/null and b/Ch08/estate/images/house10-151.gif differ diff --git a/Ch08/estate/images/house10.gif b/Ch08/estate/images/house10.gif new file mode 100644 index 0000000..ff3b51a Binary files /dev/null and b/Ch08/estate/images/house10.gif differ diff --git a/Ch08/estate/images/house11-127.gif b/Ch08/estate/images/house11-127.gif new file mode 100644 index 0000000..5c79e59 Binary files /dev/null and b/Ch08/estate/images/house11-127.gif differ diff --git a/Ch08/estate/images/house11.gif b/Ch08/estate/images/house11.gif new file mode 100644 index 0000000..d2e3c65 Binary files /dev/null and b/Ch08/estate/images/house11.gif differ diff --git a/Ch08/estate/images/house12-102.gif b/Ch08/estate/images/house12-102.gif new file mode 100644 index 0000000..33e6ebe Binary files /dev/null and b/Ch08/estate/images/house12-102.gif differ diff --git a/Ch08/estate/images/house12.gif b/Ch08/estate/images/house12.gif new file mode 100644 index 0000000..9c24452 Binary files /dev/null and b/Ch08/estate/images/house12.gif differ diff --git a/Ch08/estate/images/house_on_river.gif b/Ch08/estate/images/house_on_river.gif new file mode 100644 index 0000000..8858552 Binary files /dev/null and b/Ch08/estate/images/house_on_river.gif differ diff --git a/Ch08/estate/images/lighthouse.wmf b/Ch08/estate/images/lighthouse.wmf new file mode 100644 index 0000000..8429622 Binary files /dev/null and b/Ch08/estate/images/lighthouse.wmf differ diff --git a/Ch08/estate/images/pictures/Thumbs.db b/Ch08/estate/images/pictures/Thumbs.db new file mode 100644 index 0000000..c72458a Binary files /dev/null and b/Ch08/estate/images/pictures/Thumbs.db differ diff --git a/Ch08/estate/images/pictures/bung13-semi-thumb.gif b/Ch08/estate/images/pictures/bung13-semi-thumb.gif new file mode 100644 index 0000000..766ba86 Binary files /dev/null and b/Ch08/estate/images/pictures/bung13-semi-thumb.gif differ diff --git a/Ch08/estate/images/pictures/bung13-semi.gif b/Ch08/estate/images/pictures/bung13-semi.gif new file mode 100644 index 0000000..7114f1a Binary files /dev/null and b/Ch08/estate/images/pictures/bung13-semi.gif differ diff --git a/Ch08/estate/images/pictures/bung14-semi-thumb.gif b/Ch08/estate/images/pictures/bung14-semi-thumb.gif new file mode 100644 index 0000000..f531727 Binary files /dev/null and b/Ch08/estate/images/pictures/bung14-semi-thumb.gif differ diff --git a/Ch08/estate/images/pictures/bung14-semi.gif b/Ch08/estate/images/pictures/bung14-semi.gif new file mode 100644 index 0000000..9b21e35 Binary files /dev/null and b/Ch08/estate/images/pictures/bung14-semi.gif differ diff --git a/Ch08/estate/images/pictures/default.jpg b/Ch08/estate/images/pictures/default.jpg new file mode 100644 index 0000000..817242d Binary files /dev/null and b/Ch08/estate/images/pictures/default.jpg differ diff --git a/Ch08/estate/images/pictures/house01-191.gif b/Ch08/estate/images/pictures/house01-191.gif new file mode 100644 index 0000000..f6c8b77 Binary files /dev/null and b/Ch08/estate/images/pictures/house01-191.gif differ diff --git a/Ch08/estate/images/pictures/house01.gif b/Ch08/estate/images/pictures/house01.gif new file mode 100644 index 0000000..5fbda95 Binary files /dev/null and b/Ch08/estate/images/pictures/house01.gif differ diff --git a/Ch08/estate/images/pictures/house02-120.gif b/Ch08/estate/images/pictures/house02-120.gif new file mode 100644 index 0000000..61ae675 Binary files /dev/null and b/Ch08/estate/images/pictures/house02-120.gif differ diff --git a/Ch08/estate/images/pictures/house02.gif b/Ch08/estate/images/pictures/house02.gif new file mode 100644 index 0000000..2266507 Binary files /dev/null and b/Ch08/estate/images/pictures/house02.gif differ diff --git a/Ch08/estate/images/pictures/house03-137-semi.gif b/Ch08/estate/images/pictures/house03-137-semi.gif new file mode 100644 index 0000000..baad192 Binary files /dev/null and b/Ch08/estate/images/pictures/house03-137-semi.gif differ diff --git a/Ch08/estate/images/pictures/house03-semi.gif b/Ch08/estate/images/pictures/house03-semi.gif new file mode 100644 index 0000000..e73fcbe Binary files /dev/null and b/Ch08/estate/images/pictures/house03-semi.gif differ diff --git a/Ch08/estate/images/pictures/house04-137-semi.gif b/Ch08/estate/images/pictures/house04-137-semi.gif new file mode 100644 index 0000000..a22cec4 Binary files /dev/null and b/Ch08/estate/images/pictures/house04-137-semi.gif differ diff --git a/Ch08/estate/images/pictures/house04-semi.tif b/Ch08/estate/images/pictures/house04-semi.tif new file mode 100644 index 0000000..4bcfaad Binary files /dev/null and b/Ch08/estate/images/pictures/house04-semi.tif differ diff --git a/Ch08/estate/images/pictures/house05-104.gif b/Ch08/estate/images/pictures/house05-104.gif new file mode 100644 index 0000000..265f0fc Binary files /dev/null and b/Ch08/estate/images/pictures/house05-104.gif differ diff --git a/Ch08/estate/images/pictures/house05.gif b/Ch08/estate/images/pictures/house05.gif new file mode 100644 index 0000000..a9cd5a6 Binary files /dev/null and b/Ch08/estate/images/pictures/house05.gif differ diff --git a/Ch08/estate/images/pictures/house06-126.gif b/Ch08/estate/images/pictures/house06-126.gif new file mode 100644 index 0000000..bc21e43 Binary files /dev/null and b/Ch08/estate/images/pictures/house06-126.gif differ diff --git a/Ch08/estate/images/pictures/house06.gif b/Ch08/estate/images/pictures/house06.gif new file mode 100644 index 0000000..eee0d35 Binary files /dev/null and b/Ch08/estate/images/pictures/house06.gif differ diff --git a/Ch08/estate/images/pictures/house07-153.gif b/Ch08/estate/images/pictures/house07-153.gif new file mode 100644 index 0000000..1b9453b Binary files /dev/null and b/Ch08/estate/images/pictures/house07-153.gif differ diff --git a/Ch08/estate/images/pictures/house07.gif b/Ch08/estate/images/pictures/house07.gif new file mode 100644 index 0000000..f6a56a2 Binary files /dev/null and b/Ch08/estate/images/pictures/house07.gif differ diff --git a/Ch08/estate/images/pictures/house07.tif b/Ch08/estate/images/pictures/house07.tif new file mode 100644 index 0000000..f01183c Binary files /dev/null and b/Ch08/estate/images/pictures/house07.tif differ diff --git a/Ch08/estate/images/pictures/house08.jpg b/Ch08/estate/images/pictures/house08.jpg new file mode 100644 index 0000000..3ae4faf Binary files /dev/null and b/Ch08/estate/images/pictures/house08.jpg differ diff --git a/Ch08/estate/images/pictures/house08.tif b/Ch08/estate/images/pictures/house08.tif new file mode 100644 index 0000000..cff6af7 Binary files /dev/null and b/Ch08/estate/images/pictures/house08.tif differ diff --git a/Ch08/estate/images/pictures/house09-semi-110.gif b/Ch08/estate/images/pictures/house09-semi-110.gif new file mode 100644 index 0000000..03e176b Binary files /dev/null and b/Ch08/estate/images/pictures/house09-semi-110.gif differ diff --git a/Ch08/estate/images/pictures/house09-semi.gif b/Ch08/estate/images/pictures/house09-semi.gif new file mode 100644 index 0000000..d690a0b Binary files /dev/null and b/Ch08/estate/images/pictures/house09-semi.gif differ diff --git a/Ch08/estate/images/pictures/house10-151.gif b/Ch08/estate/images/pictures/house10-151.gif new file mode 100644 index 0000000..a027584 Binary files /dev/null and b/Ch08/estate/images/pictures/house10-151.gif differ diff --git a/Ch08/estate/images/pictures/house10.gif b/Ch08/estate/images/pictures/house10.gif new file mode 100644 index 0000000..ff3b51a Binary files /dev/null and b/Ch08/estate/images/pictures/house10.gif differ diff --git a/Ch08/estate/images/pictures/house11-127.gif b/Ch08/estate/images/pictures/house11-127.gif new file mode 100644 index 0000000..5c79e59 Binary files /dev/null and b/Ch08/estate/images/pictures/house11-127.gif differ diff --git a/Ch08/estate/images/pictures/house11.gif b/Ch08/estate/images/pictures/house11.gif new file mode 100644 index 0000000..d2e3c65 Binary files /dev/null and b/Ch08/estate/images/pictures/house11.gif differ diff --git a/Ch08/estate/images/pictures/house12-102.gif b/Ch08/estate/images/pictures/house12-102.gif new file mode 100644 index 0000000..33e6ebe Binary files /dev/null and b/Ch08/estate/images/pictures/house12-102.gif differ diff --git a/Ch08/estate/images/pictures/house12.gif b/Ch08/estate/images/pictures/house12.gif new file mode 100644 index 0000000..9c24452 Binary files /dev/null and b/Ch08/estate/images/pictures/house12.gif differ diff --git a/Ch08/estate/images/pictures/house_on_river.gif b/Ch08/estate/images/pictures/house_on_river.gif new file mode 100644 index 0000000..8858552 Binary files /dev/null and b/Ch08/estate/images/pictures/house_on_river.gif differ diff --git a/Ch08/estate/images/rosette-128.png b/Ch08/estate/images/rosette-128.png new file mode 100644 index 0000000..77dd785 Binary files /dev/null and b/Ch08/estate/images/rosette-128.png differ diff --git a/Ch08/estate/images/thumbs/Thumbs.db b/Ch08/estate/images/thumbs/Thumbs.db new file mode 100644 index 0000000..c72458a Binary files /dev/null and b/Ch08/estate/images/thumbs/Thumbs.db differ diff --git a/Ch08/estate/images/thumbs/bung13-semi-thumb.gif b/Ch08/estate/images/thumbs/bung13-semi-thumb.gif new file mode 100644 index 0000000..766ba86 Binary files /dev/null and b/Ch08/estate/images/thumbs/bung13-semi-thumb.gif differ diff --git a/Ch08/estate/images/thumbs/bung13-semi.gif b/Ch08/estate/images/thumbs/bung13-semi.gif new file mode 100644 index 0000000..7114f1a Binary files /dev/null and b/Ch08/estate/images/thumbs/bung13-semi.gif differ diff --git a/Ch08/estate/images/thumbs/bung14-semi-thumb.gif b/Ch08/estate/images/thumbs/bung14-semi-thumb.gif new file mode 100644 index 0000000..f531727 Binary files /dev/null and b/Ch08/estate/images/thumbs/bung14-semi-thumb.gif differ diff --git a/Ch08/estate/images/thumbs/bung14-semi.gif b/Ch08/estate/images/thumbs/bung14-semi.gif new file mode 100644 index 0000000..9b21e35 Binary files /dev/null and b/Ch08/estate/images/thumbs/bung14-semi.gif differ diff --git a/Ch08/estate/images/thumbs/default.jpg b/Ch08/estate/images/thumbs/default.jpg new file mode 100644 index 0000000..d04225e Binary files /dev/null and b/Ch08/estate/images/thumbs/default.jpg differ diff --git a/Ch08/estate/images/thumbs/house01-191.gif b/Ch08/estate/images/thumbs/house01-191.gif new file mode 100644 index 0000000..f6c8b77 Binary files /dev/null and b/Ch08/estate/images/thumbs/house01-191.gif differ diff --git a/Ch08/estate/images/thumbs/house01.gif b/Ch08/estate/images/thumbs/house01.gif new file mode 100644 index 0000000..5fbda95 Binary files /dev/null and b/Ch08/estate/images/thumbs/house01.gif differ diff --git a/Ch08/estate/images/thumbs/house02-120.gif b/Ch08/estate/images/thumbs/house02-120.gif new file mode 100644 index 0000000..61ae675 Binary files /dev/null and b/Ch08/estate/images/thumbs/house02-120.gif differ diff --git a/Ch08/estate/images/thumbs/house02.gif b/Ch08/estate/images/thumbs/house02.gif new file mode 100644 index 0000000..2266507 Binary files /dev/null and b/Ch08/estate/images/thumbs/house02.gif differ diff --git a/Ch08/estate/images/thumbs/house03-137-semi.gif b/Ch08/estate/images/thumbs/house03-137-semi.gif new file mode 100644 index 0000000..baad192 Binary files /dev/null and b/Ch08/estate/images/thumbs/house03-137-semi.gif differ diff --git a/Ch08/estate/images/thumbs/house03-semi.gif b/Ch08/estate/images/thumbs/house03-semi.gif new file mode 100644 index 0000000..e73fcbe Binary files /dev/null and b/Ch08/estate/images/thumbs/house03-semi.gif differ diff --git a/Ch08/estate/images/thumbs/house04-137-semi.gif b/Ch08/estate/images/thumbs/house04-137-semi.gif new file mode 100644 index 0000000..a22cec4 Binary files /dev/null and b/Ch08/estate/images/thumbs/house04-137-semi.gif differ diff --git a/Ch08/estate/images/thumbs/house04-semi.tif b/Ch08/estate/images/thumbs/house04-semi.tif new file mode 100644 index 0000000..4bcfaad Binary files /dev/null and b/Ch08/estate/images/thumbs/house04-semi.tif differ diff --git a/Ch08/estate/images/thumbs/house05-104.gif b/Ch08/estate/images/thumbs/house05-104.gif new file mode 100644 index 0000000..265f0fc Binary files /dev/null and b/Ch08/estate/images/thumbs/house05-104.gif differ diff --git a/Ch08/estate/images/thumbs/house05.gif b/Ch08/estate/images/thumbs/house05.gif new file mode 100644 index 0000000..a9cd5a6 Binary files /dev/null and b/Ch08/estate/images/thumbs/house05.gif differ diff --git a/Ch08/estate/images/thumbs/house06-126.gif b/Ch08/estate/images/thumbs/house06-126.gif new file mode 100644 index 0000000..bc21e43 Binary files /dev/null and b/Ch08/estate/images/thumbs/house06-126.gif differ diff --git a/Ch08/estate/images/thumbs/house06.gif b/Ch08/estate/images/thumbs/house06.gif new file mode 100644 index 0000000..eee0d35 Binary files /dev/null and b/Ch08/estate/images/thumbs/house06.gif differ diff --git a/Ch08/estate/images/thumbs/house07-153.gif b/Ch08/estate/images/thumbs/house07-153.gif new file mode 100644 index 0000000..1b9453b Binary files /dev/null and b/Ch08/estate/images/thumbs/house07-153.gif differ diff --git a/Ch08/estate/images/thumbs/house07.gif b/Ch08/estate/images/thumbs/house07.gif new file mode 100644 index 0000000..f6a56a2 Binary files /dev/null and b/Ch08/estate/images/thumbs/house07.gif differ diff --git a/Ch08/estate/images/thumbs/house07.tif b/Ch08/estate/images/thumbs/house07.tif new file mode 100644 index 0000000..f01183c Binary files /dev/null and b/Ch08/estate/images/thumbs/house07.tif differ diff --git a/Ch08/estate/images/thumbs/house08.jpg b/Ch08/estate/images/thumbs/house08.jpg new file mode 100644 index 0000000..3ae4faf Binary files /dev/null and b/Ch08/estate/images/thumbs/house08.jpg differ diff --git a/Ch08/estate/images/thumbs/house08.tif b/Ch08/estate/images/thumbs/house08.tif new file mode 100644 index 0000000..cff6af7 Binary files /dev/null and b/Ch08/estate/images/thumbs/house08.tif differ diff --git a/Ch08/estate/images/thumbs/house09-semi-110.gif b/Ch08/estate/images/thumbs/house09-semi-110.gif new file mode 100644 index 0000000..03e176b Binary files /dev/null and b/Ch08/estate/images/thumbs/house09-semi-110.gif differ diff --git a/Ch08/estate/images/thumbs/house09-semi.gif b/Ch08/estate/images/thumbs/house09-semi.gif new file mode 100644 index 0000000..d690a0b Binary files /dev/null and b/Ch08/estate/images/thumbs/house09-semi.gif differ diff --git a/Ch08/estate/images/thumbs/house10-151.gif b/Ch08/estate/images/thumbs/house10-151.gif new file mode 100644 index 0000000..a027584 Binary files /dev/null and b/Ch08/estate/images/thumbs/house10-151.gif differ diff --git a/Ch08/estate/images/thumbs/house10.gif b/Ch08/estate/images/thumbs/house10.gif new file mode 100644 index 0000000..ff3b51a Binary files /dev/null and b/Ch08/estate/images/thumbs/house10.gif differ diff --git a/Ch08/estate/images/thumbs/house11-127.gif b/Ch08/estate/images/thumbs/house11-127.gif new file mode 100644 index 0000000..5c79e59 Binary files /dev/null and b/Ch08/estate/images/thumbs/house11-127.gif differ diff --git a/Ch08/estate/images/thumbs/house11.gif b/Ch08/estate/images/thumbs/house11.gif new file mode 100644 index 0000000..d2e3c65 Binary files /dev/null and b/Ch08/estate/images/thumbs/house11.gif differ diff --git a/Ch08/estate/images/thumbs/house12-102.gif b/Ch08/estate/images/thumbs/house12-102.gif new file mode 100644 index 0000000..33e6ebe Binary files /dev/null and b/Ch08/estate/images/thumbs/house12-102.gif differ diff --git a/Ch08/estate/images/thumbs/house12.gif b/Ch08/estate/images/thumbs/house12.gif new file mode 100644 index 0000000..9c24452 Binary files /dev/null and b/Ch08/estate/images/thumbs/house12.gif differ diff --git a/Ch08/estate/images/thumbs/house_on_river.gif b/Ch08/estate/images/thumbs/house_on_river.gif new file mode 100644 index 0000000..8858552 Binary files /dev/null and b/Ch08/estate/images/thumbs/house_on_river.gif differ diff --git a/Ch08/estate/includes/another-button.php b/Ch08/estate/includes/another-button.php new file mode 100644 index 0000000..ebfe024 --- /dev/null +++ b/Ch08/estate/includes/another-button.php @@ -0,0 +1,17 @@ +
    + +
    \ No newline at end of file diff --git a/Ch08/estate/includes/footer.php b/Ch08/estate/includes/footer.php new file mode 100644 index 0000000..742b705 --- /dev/null +++ b/Ch08/estate/includes/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2017 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch08/estate/includes/header.php b/Ch08/estate/includes/header.php new file mode 100644 index 0000000..a4adc1e --- /dev/null +++ b/Ch08/estate/includes/header.php @@ -0,0 +1,9 @@ +
    +
    +

    Devon Real Estate

    +

    Try our award winning service

    +
    +
    +Rosette + diff --git a/Ch08/estate/includes/header_3btn.php b/Ch08/estate/includes/header_3btn.php new file mode 100644 index 0000000..1c84dac --- /dev/null +++ b/Ch08/estate/includes/header_3btn.php @@ -0,0 +1,15 @@ +
    +
    +

    Devon Real Estate

    +

    Try our award winning service

    +
    + +
    +Rosette \ No newline at end of file diff --git a/Ch08/estate/includes/header_4btn.php b/Ch08/estate/includes/header_4btn.php new file mode 100644 index 0000000..68857d2 --- /dev/null +++ b/Ch08/estate/includes/header_4btn.php @@ -0,0 +1,17 @@ +
    +
    +

    Devon Real Estate

    +

    Try our award winning service

    +
    + +
    +Rosette \ No newline at end of file diff --git a/Ch08/estate/includes/header_advert.php b/Ch08/estate/includes/header_advert.php new file mode 100644 index 0000000..6023e3a --- /dev/null +++ b/Ch08/estate/includes/header_advert.php @@ -0,0 +1,14 @@ +
    +
    +

    Devon Real Estate

    +

    Try our award winning service

    +
    + +
    +Rosette \ No newline at end of file diff --git a/Ch08/estate/includes/header_found_houses.php b/Ch08/estate/includes/header_found_houses.php new file mode 100644 index 0000000..753cf6c --- /dev/null +++ b/Ch08/estate/includes/header_found_houses.php @@ -0,0 +1,18 @@ + +
    +
    +

    Devon Real Estate

    +

    Try our award winning service

    +
    + +
    +Rosette + + + \ No newline at end of file diff --git a/Ch08/estate/includes/menu.php b/Ch08/estate/includes/menu.php new file mode 100644 index 0000000..ae50f4b --- /dev/null +++ b/Ch08/estate/includes/menu.php @@ -0,0 +1,26 @@ + + + +
    + +
    \ No newline at end of file diff --git a/Ch08/estate/index.php b/Ch08/estate/index.php new file mode 100644 index 0000000..0d43002 --- /dev/null +++ b/Ch08/estate/index.php @@ -0,0 +1,120 @@ + + + + + Estate Home Page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +

    Search for your dream house

    +
    IMPORTANT: Select an item in + ALL fields otherwise the search will not succeed
    +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    All houses are situated in the beautiful green rolling countryside of Devon, England, UK
    + SW England +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch08/estate/login.php b/Ch08/estate/login.php new file mode 100644 index 0000000..136b2eb --- /dev/null +++ b/Ch08/estate/login.php @@ -0,0 +1,85 @@ + + + + Login page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    + + +
    +

    Login

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    +
    + + +'; + include('includes/menu.php'); + echo ''; } +?> +
    +
    +
    +
    + +
    +
    +
    +
    + + diff --git a/Ch08/estate/logout.php b/Ch08/estate/logout.php new file mode 100644 index 0000000..d8abea1 --- /dev/null +++ b/Ch08/estate/logout.php @@ -0,0 +1,18 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password = filter_var( $_POST['password'], FILTER_SANITIZE_STRING); +$string_length = strlen($password); +if (empty($password)){ +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} +} + if (empty($errors)) { // If everything's OK. #1 +// Retrieve the user_id, psword, first_name and user_level for that +// email/password combination + $query = "SELECT userid, password, first_name, user_level FROM users "; + $query .= "WHERE email=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $email); + + // execute query + + mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); +if (mysqli_num_rows($result) == 1) { +//if one database row (record) matches the input:- +// Start the session, fetch the record and insert the +// values in an array +if (password_verify($password, $row[1])) { //#2 +session_start(); +// Ensure that the user level is an integer. +$_SESSION['user_id'] = $row[0]; +$_SESSION['user_level'] = (int) $row[3]; +// Use a ternary operation to set the URL #3 +$url = ($_SESSION['user_level'] === 1) ? 'advert.php' : + 'members-page.php'; +header('Location: ' . $url); +// Make the browser load either the members or the admin page +} else { // No password match was made. +$errors[] = 'E-mail/Password entered does not match our records. '; +$errors[] = 'Perhaps your fee has not yet been processed from '; +$errors[] = ' PayPal or the credit card.'; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} else { // No e-mail match was made. +$errors[] = 'E-mail/Password entered does not match our records. '; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} +if (!empty($errors)) { + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + echo "

    $errorstring

    "; + }// End of if (!empty($errors)) IF. + +} + catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +} // no else to allow user to enter values +?> \ No newline at end of file diff --git a/Ch08/estate/process-register-page.php b/Ch08/estate/process-register-page.php new file mode 100644 index 0000000..d624618 --- /dev/null +++ b/Ch08/estate/process-register-page.php @@ -0,0 +1,128 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password1trim = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); +$string_length = strlen($password1trim); +if (empty($password1trim)){ // #7 +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password1trim)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ +$password2trim = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); +if($password1trim === $password2trim) { // #9 +$password = $password1trim; +}else{ +$errors[] = 'Your two password do not match.'; +$errors[] = 'Please try again'; +} +} +} +if (empty($errors)) { // If everything's OK. +// If no problems encountered, register user in the database +//Determine whether the email address has already been registered +$query = "SELECT userid FROM users WHERE email = ? "; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +mysqli_stmt_bind_param($q,'s', $emailtrim); +mysqli_stmt_execute($q); +$result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0){//The email address has not been registered +//already therefore register the user in the users table + //-------------Valid Entries - Save to database ----- + //Start of the SUCCESSFUL SECTION. i.e all the required fields were filled out + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + // Register the user in the database... + + $query = "INSERT INTO users (userid, first_name, last_name, email, password) "; + $query .= "VALUES "; + $query .= "(' ',?,?,?,?)"; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'ssss', $first_nametrim, $last_nametrim, $emailtrim, $hashed_password); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + $complete = "Userid Created!"; + } else { + // echo 'Invalid query:' . $dbcon->error; + $errorstring = "System is busy, please try later"; + echo "

    $errorstring

    "; + } + }else{//The email address is already registered + $errorstring = 'The email address is already registered.'; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +$errorstring = 'Error! The following error(s) occurred: '; +foreach ($errors as $msg) { // Print each error. +$errorstring .= " - $msg
    \n"; + } +$errorstring .= 'Please try again.'; +echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch08/estate/rosette-128.png b/Ch08/estate/rosette-128.png new file mode 100644 index 0000000..77dd785 Binary files /dev/null and b/Ch08/estate/rosette-128.png differ diff --git a/Ch08/estate/rosette.jpeg b/Ch08/estate/rosette.jpeg new file mode 100644 index 0000000..f740b43 Binary files /dev/null and b/Ch08/estate/rosette.jpeg differ diff --git a/Ch08/estate/safer-register-page.php b/Ch08/estate/safer-register-page.php new file mode 100644 index 0000000..a836015 --- /dev/null +++ b/Ch08/estate/safer-register-page.php @@ -0,0 +1,141 @@ + + + + + Register Page + + + + + + + + +
    + +
    + +
    + + + + +
    + +
    +
    +

    Register

    +

    + +

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    + + diff --git a/Ch08/estate/transparent.css b/Ch08/estate/transparent.css new file mode 100644 index 0000000..b25f2a8 --- /dev/null +++ b/Ch08/estate/transparent.css @@ -0,0 +1,20 @@ +body { background:linear-gradient(green, #9ff781); font-family:arial; font-size: 100%; +} +html { min-height: 100% } +#includeheader {border:10px white solid;} +} +#container { + margin:auto; +} +h2 { margin-top: 20px; } +label { color: black; } +#submit {margin: 0px; background:#559a55; border: 5px outset #559a55; width: 140px;} +#includemenu {padding-top: 10px; padding-bottom: 10px; padding-right: 0px; } +#includefooter {background:#68CE53; padding-top: 5px; padding-bottom: 5px; margin: 0px;} +#includeheader {width:90%; background:url(images/header3.jpg); background-repeat:no-repeat; margin-bottom: 0px; padding:40px; padding-bottom: 0px; color: white;} +#contents {background-color:transparent ;margin-top: -135px; border:10px white solid; color: white; width: 90%; } +#rosette1 { position:relative; left:750px; top:-95px; } +#rosette { position:relative; left:850px; top:-95px; } +#buttons {background:#559a55; border: 5px outset #559a55;} + + diff --git a/Ch09/birds/birds.css b/Ch09/birds/birds.css new file mode 100644 index 0000000..a6102c9 --- /dev/null +++ b/Ch09/birds/birds.css @@ -0,0 +1,15 @@ + +body {text-align:center; background-color:#CCFF99; color:green; +font-family: "times new roman"; +font-size: 120%; margin: auto; } +#container {margin:auto; border:5px black solid; } + +header {color:white; background-color:#CCFF99;} +} +label { color: black; } +#submit {margin: 0px; background:#559a55; border: 5px outset #559a55; width: 140px;} +#includemenu {padding-top: 10px; padding-bottom: 10px; padding-right: 0px;} +#includefooter {background:#68CE53; padding-top: 5px; padding-bottom: 5px; margin: 0px;} +#includeheader { height:auto; background:#95b522; margin-bottom: 0px; padding:0px; background:url('images/header3.jpg'); background-repeat:no-repeat;} +#contents {background-color:transparent ;margin-top: -7px; color: black; margin: 0px; padding: 0px;} +#buttons {background:#559a55; border: 5px outset #559a55;} diff --git a/Ch09/birds/birds.php b/Ch09/birds/birds.php new file mode 100644 index 0000000..50b7e03 --- /dev/null +++ b/Ch09/birds/birds.php @@ -0,0 +1,118 @@ + + + + + Birds Home Page + + + + + + + +
    + +
    + +
    + +
    +
    + + + +
    +

    The Birds that can be seen on our Reserves

    +

    + + + + + + + + + + + + '; + } + echo '
    Birds NameRarityBest Time
    ' . $bird_name . '' . $rarity . '' . $best_time . '
    '; // Close the table + mysqli_free_result ($result); // Free up the resources +} else { // If it did not run OK +// Message + echo '

    The current birds could not be retrieved. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?>

    +
    + + +
    + +
    + +
    +
    +
    + + diff --git a/Ch09/birds/birdsdb.sql b/Ch09/birds/birdsdb.sql new file mode 100644 index 0000000..781adc6 --- /dev/null +++ b/Ch09/birds/birdsdb.sql @@ -0,0 +1,210 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Jul 27, 2018 at 07:10 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `birdsdb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `birds` +-- + +CREATE TABLE `birds` ( + `bird_id` mediumint(4) UNSIGNED NOT NULL, + `bird_name` tinytext NOT NULL, + `rarity` tinytext NOT NULL, + `best_time` tinytext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `birds` +-- + +INSERT INTO `birds` (`bird_id`, `bird_name`, `rarity`, `best_time`) VALUES +(1, 'Golden Eye', 'Common', 'Winter'), +(2, 'Wryneck', 'Rare', 'Summer'), +(3, 'Avocet', 'Common', 'Winter'), +(4, 'Moorhen', 'Common', 'Anytime'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `location` +-- + +CREATE TABLE `location` ( + `location_id` mediumint(4) UNSIGNED NOT NULL, + `location` tinytext NOT NULL, + `location_type` tinytext NOT NULL, + `bird_id` mediumint(4) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `location` +-- + +INSERT INTO `location` (`location_id`, `location`, `location_type`, `bird_id`) VALUES +(1, 'Southpark', 'Ponds', 4), +(2, 'Wetlands', 'Estuary', 3), +(3, 'Lakeland', 'Lakes', 1), +(4, 'Moorfield', 'Moorland', 2), +(5, 'Heathville', 'Heath', 2); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prices` +-- + +CREATE TABLE `prices` ( + `oneyeargb` decimal(6,0) UNSIGNED NOT NULL, + `oneyearus` decimal(6,0) UNSIGNED NOT NULL, + `fiveyeargb` decimal(6,0) UNSIGNED NOT NULL, + `fiveyearus` decimal(6,0) UNSIGNED NOT NULL, + `militarygb` decimal(6,0) UNSIGNED NOT NULL, + `militaryus` decimal(6,0) UNSIGNED NOT NULL, + `u21gb` decimal(6,0) UNSIGNED NOT NULL, + `u21us` decimal(6,0) UNSIGNED NOT NULL, + `minpricegb` decimal(6,0) UNSIGNED NOT NULL, + `minpriceus` decimal(6,0) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `prices` +-- + +INSERT INTO `prices` (`oneyeargb`, `oneyearus`, `fiveyeargb`, `fiveyearus`, `militarygb`, `militaryus`, `u21gb`, `u21us`, `minpricegb`, `minpriceus`) VALUES +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `reserves_info` +-- + +CREATE TABLE `reserves_info` ( + `reserves_id` mediumint(4) UNSIGNED NOT NULL, + `bird_hides` enum('yes','no') CHARACTER SET utf8 NOT NULL, + `entrance_member` tinytext CHARACTER SET utf8 NOT NULL, + `entr_non_member` tinytext CHARACTER SET utf8 NOT NULL, + `location_id` mediumint(4) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci; + +-- +-- Dumping data for table `reserves_info` +-- + +INSERT INTO `reserves_info` (`reserves_id`, `bird_hides`, `entrance_member`, `entr_non_member`, `location_id`) VALUES +(1, 'yes', 'free', '1', 1), +(2, 'yes', '1', '2', 2), +(3, 'yes', 'free', '1', 3), +(4, 'no', 'free', 'free', 4), +(5, 'no', 'free', 'free', 5); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `userid` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `class` char(20) NOT NULL, + `user_level` tinyint(2) UNSIGNED NOT NULL, + `address1` varchar(50) NOT NULL, + `address2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `secret` varchar(60) DEFAULT NULL, + `paid` enum('No','Yes') NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`userid`, `title`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `class`, `user_level`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `secret`, `paid`) VALUES +(1, 'Mr', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UiiBhmXca.0/bwopveFq8uInuX.EVrecinUQYQG546WjAWwZLJNoe', '2017-12-06 08:43:41', '30', 0, '4 The Street', 'The Village', 'Townsville', 'USA', 'WA', '0123777888', NULL, 'Yes'), +(2, 'Mr', 'Jack', 'Smith', 'jsmith@outcook.com', '$2y$10$NjlsajfCITeb.oDXqu9Neuguh3PBKL5EaqZ5ClfW76nVSnW.W.XNO', '2017-12-06 08:47:24', '30', 1, '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', NULL, 'Yes'), +(4, 'Ms', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$5KM8jy5MwHIgfVchsdfE8OvuF1cT2VYqU6mte2CWBw1HjmEv3r.ES', '2017-12-06 12:20:33', '2', 0, '6 The Street', '', 'Townsville', 'UK', 'EX9 9PG', '01234777888', NULL, 'Yes'), +(5, 'Mr', 'Patrick', 'O\'Hara', 'pohara@myisp.org.uk', '$2y$10$0nmGDVmHdWusgFJRmVZADeL43Y7HCPViBrHj/Z2betxiMdMx5Y2sC', '2017-12-06 12:27:32', '30', 0, '5 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', NULL, 'Yes'), +(6, 'Mr', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$KCQhEftEJouWPfuOOVoRVOECY/oJTluxHRr85fWlz6nsfN4OHtCie', '2017-12-06 17:02:16', '30', 0, '6 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PS', '', NULL, 'Yes'), +(7, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$IrQE3TTkWzNm93FP/VYf.O/yMWDJDpIn/.qjrmvN.I97fvakynuza', '2017-12-06 17:11:44', '30', 0, '7 The Street', 'The Village', 'Townsville', 'UK', 'EXP 6PG', '01234777888', NULL, 'Yes'), +(8, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$R2auBMKMe/Qw2fFr8D.S8eUEENUz8r.YUth5NHAyskNYupUzBen5O', '2017-12-06 17:18:30', '30', 0, '7 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', NULL, 'Yes'), +(9, 'Mrs', 'Annie', 'Mossity', 'amossity@myisp.org.uk', '$2y$10$amqmyEfaOfiZ0MkIzdO90uZMPw4Mi/4RR70nNd0nxaZSOlxlr.8DC', '2017-12-06 17:24:42', '30', 0, '4 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', NULL, 'Yes'), +(10, 'Mr', 'Percy', 'Veer', 'pveer@myisp.com', '$2y$10$Wvdx/YO4cCcOQvyMVVtapO3F/eiz2Ow3yU9VcczGMC.dcgwbgIXMS', '2017-12-06 17:28:53', '30', 0, '7 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PG', '01234777888', NULL, 'Yes'), +(11, 'Mr', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$cTmJVcuUmTpCOIdQJ8MG3uwLmG7M7V3iE8zPXiNW2PQEdDQZMBftO', '2017-12-06 17:39:30', '30', 0, '5 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '', NULL, 'Yes'), +(12, 'Mr', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$YUYnU8UvOF/WUJ5h4VK4Qe.I48ZcAbedjPiDekKHlODduqGdJoI9i', '2017-12-06 18:02:04', '30', 0, '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '01234777888', NULL, 'Yes'), +(13, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$k9sMvE001164jjzJLs.OpOmb9LtluUEbR4GQ4RT5/rvSPNIqbL6gC', '2017-12-07 17:39:34', '30', 0, '6 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', NULL, 'Yes'), +(14, 'Mr', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$TOr.IZq/joHIKSk0Oo.jE.yWau48sUSgtC5TzKJ0sl0AoO2Bsk3lW', '2017-12-08 12:16:58', '30', 0, '5 The Street', '', 'Townsville', 'UK', 'EX7 9PG', '01234777888', NULL, 'Yes'), +(16, 'Miss', 'Lynn', 'Seed', 'lseed@myisp.com', '$2y$10$nEs3Zhh4V5ZznpcPzGs9gOWupjY2NgV87DPpLu2DjqsdyBNRjf4/C', '2017-12-16 20:03:16', '30', 0, '6 The Street', '', 'Townsville', 'UK', 'EX24 6PG', '01234777888', NULL, 'Yes'), +(17, 'Mr', 'Barry', 'Tone', 'btone@myisp.net', '$2y$10$w4zMq7ij7NmVDeBBKDSmbu963EwchZwAHPZmgZmTQAQ8Gha2jTD5W', '2017-12-16 20:16:40', '30', 0, '2 The Street', '', 'Townsville', 'USA', 'CA12345', '', NULL, 'Yes'), +(30, 'Mr', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$lePdxFz7ZKn/bJ41BS0h/ehWyIL2ZgK123iPQJahNCaRjgxVY3Rfq', '2017-12-29 11:28:43', '30', 0, '2 The Street', 'The Village', 'Townsville', 'Germany', 'BL1234', '', NULL, 'Yes'), +(31, 'Miss', 'Dee', 'Jected', 'djected@myisp.org.uk', '$2y$10$ujpV7w4blsTdQFWOsE1fiOFYtj9zN4w0WcK5V4WJ60Pc5HWodWlGC', '2017-12-29 11:48:04', '30', 0, '3 The Street', 'The Village', 'Townsville', 'UK', 'EX3 1TH', '', NULL, 'Yes'), +(32, 'Mr', 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$Yu.c/cw/TSFa9vcMBGAfAe5vzyOwp3SZarBVc/9vEksfp.F8BzSiW', '2017-12-29 11:58:51', '30', 0, '2 The Street', '', 'Townsville', 'UK', 'EX24 6PS', '01234777888', NULL, 'Yes'), +(40, 'Mr', 'James', 'Smith', 'jsmith@outcook.com', '$2y$10$ex0.2VNU/lQv73UvaCXfDOwa/xiH72PpuiRD20KIiufgSlqAT0A2.', '2018-03-02 17:05:00', '5', 0, '123 Main Street', '', 'Key West', 'FL', '33040', '305-555-5555', NULL, 'No'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `reserves_info` +-- +ALTER TABLE `reserves_info` + ADD PRIMARY KEY (`reserves_id`), + ADD KEY `location_id` (`location_id`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`userid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `reserves_info` +-- +ALTER TABLE `reserves_info` + MODIFY `reserves_id` mediumint(4) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `userid` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=46; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch09/birds/cap.php b/Ch09/birds/cap.php new file mode 100644 index 0000000..201053b --- /dev/null +++ b/Ch09/birds/cap.php @@ -0,0 +1,17 @@ +Are you human? Click recaptcha"; + header( "refresh:1;" ); + } + } + else { echo "

    Are you human? Click recaptcha!

    "; + header( "refresh:1;" ); + } + +?> \ No newline at end of file diff --git a/Ch09/birds/footer.php b/Ch09/birds/footer.php new file mode 100644 index 0000000..742b705 --- /dev/null +++ b/Ch09/birds/footer.php @@ -0,0 +1,5 @@ +

    Copyright © Adrian West & Steve Prettyman 2017 Designed by +Adrian West and +Steve Prettyman Valid +CSS & +HTML5

    \ No newline at end of file diff --git a/Ch09/birds/images/Thumbs.db b/Ch09/birds/images/Thumbs.db new file mode 100644 index 0000000..1d6d961 Binary files /dev/null and b/Ch09/birds/images/Thumbs.db differ diff --git a/Ch09/birds/images/header3.jpg b/Ch09/birds/images/header3.jpg new file mode 100644 index 0000000..8fbd7c3 Binary files /dev/null and b/Ch09/birds/images/header3.jpg differ diff --git a/Ch09/birds/images/vertical_solution_PP.png b/Ch09/birds/images/vertical_solution_PP.png new file mode 100644 index 0000000..8693bd4 Binary files /dev/null and b/Ch09/birds/images/vertical_solution_PP.png differ diff --git a/Ch09/birds/includes/footer.php b/Ch09/birds/includes/footer.php new file mode 100644 index 0000000..6f56f56 --- /dev/null +++ b/Ch09/birds/includes/footer.php @@ -0,0 +1 @@ +

    Footer goes here

    \ No newline at end of file diff --git a/Ch09/birds/includes/header.php b/Ch09/birds/includes/header.php new file mode 100644 index 0000000..5c91ba7 --- /dev/null +++ b/Ch09/birds/includes/header.php @@ -0,0 +1,24 @@ + + + + +
    +
    The Devon Bird Reserves
    +
    +
    + +
    diff --git a/Ch09/birds/includes/info-col-cards.php b/Ch09/birds/includes/info-col-cards.php new file mode 100644 index 0000000..1184ff5 --- /dev/null +++ b/Ch09/birds/includes/info-col-cards.php @@ -0,0 +1,6 @@ +
    +

    This is the information column

    +

    Web design by
    A W West and +
    Steve Prettyman

    + Pay by PayPal or Credit card +
    diff --git a/Ch09/birds/includes/info-col.php b/Ch09/birds/includes/info-col.php new file mode 100644 index 0000000..1c1ae88 --- /dev/null +++ b/Ch09/birds/includes/info-col.php @@ -0,0 +1,3 @@ +

    This is the information column

    +

    Information area

    + diff --git a/Ch09/birds/includes/nav.php b/Ch09/birds/includes/nav.php new file mode 100644 index 0000000..b7fca5e --- /dev/null +++ b/Ch09/birds/includes/nav.php @@ -0,0 +1,29 @@ + +
    + +
    \ No newline at end of file diff --git a/Ch09/birds/index.php b/Ch09/birds/index.php new file mode 100644 index 0000000..d4e37bc --- /dev/null +++ b/Ch09/birds/index.php @@ -0,0 +1,60 @@ + + + + + Birds Home Page + + + + + + + +
    + +
    + +
    + +
    +
    + + + +
    +

    Help Save Our Devon Birds From Extinction

    +
    +

    The Devon bird reserves were established in an effort to combat the massive decline +in the bird population. Farmers (the self proclaimed Guardians of the Countryside!) spray +insecticides, weed killers and pesticides that kill the birds' main source of food. They +also rip out the hedges that provide the birds with nesting sites and their means of +travelling safely from field to field. Any birds that survive will probably be shot to +satisfy a blood lust for living targets

    +
    +
    +

    Become a member and support our cause

    +

    The annual membership fee includes free or reduced entrance fees to the reserves, +a free quarterly magazine, news updates and more.

    +
    +
    + + +
    + +
    + +
    +
    + + diff --git a/Ch09/birds/join-2.php b/Ch09/birds/join-2.php new file mode 100644 index 0000000..762a1d4 --- /dev/null +++ b/Ch09/birds/join-2.php @@ -0,0 +1,121 @@ + + + + + Two Tables Page + + + + + + + +
    + +
    + +
    + +
    +
    + + + +
    +

    The location and habitat of the Devon Bird Reserves

    +

    + + + + + + + + + + + + + + '; + } + echo '
    LocationBird NameRarityBest Time
    ' . $location . '' . $bird_name . '' . $rarity . '' . $best_time . '
    '; // Close the table + mysqli_free_result ($result); // Free up the resources +} else { // If it did not run OK +// Message + echo '

    The current birds or locations could not be retrieved. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?>

    +
    + + +
    + +
    + +
    +
    +
    + + diff --git a/Ch09/birds/join-3.php b/Ch09/birds/join-3.php new file mode 100644 index 0000000..35f741d --- /dev/null +++ b/Ch09/birds/join-3.php @@ -0,0 +1,115 @@ + + + + + Three Tables Page + + + + + + + +
    + +
    + +
    + +
    +
    + + + +
    +

    The location and habitat of the Devon Bird Reserves

    +

    + + + + + + + + + + + + + + + + + + '; + } + echo '
    Birds NameBest TimeLocationBird HidesEntrance MemberEntrance Non-Member
    ' . $bird_name . '' . $best_time . '' . $location . '' . $bird_hides . '' . $entrance_member . '' . $entrance_non_member . '
    '; // Close the table + mysqli_free_result ($result); // Free up the resources +} else { // If it did not run OK +// Message + echo '

    The current data could not be retrieved. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection +} + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?>

    +
    + + +
    + +
    + +
    +
    +
    + + diff --git a/Ch09/birds/location.php b/Ch09/birds/location.php new file mode 100644 index 0000000..cf6d198 --- /dev/null +++ b/Ch09/birds/location.php @@ -0,0 +1,75 @@ + + + +View the location page + + + + + +
    +
    +
    + +
    + + +
    + +
    +
    +

    The Locations and Habitats of the Devon Bird Reserves

    +

    + +Location +Location type +'; +// Fetch and print all the records +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + echo ' + ' . $row['location'] . ' + ' . $row['location_type'] . ' + '; + } + echo ''; // Close the table + mysqli_free_result ($result); // Free up the resources +} else { // If it did not run OK +// Message + echo '

    The current location could not be retrieved. We apologize for any inconvenience.

    '; + // Debugging message + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ +print "An Exception occurred. Message: " . $e->getMessage(); +} +catch(Error $e) +{ +print "An Error occurred. Message: " . $e->getMessage(); +} +?>

    +
    +
    + +
    +
    +
    + diff --git a/Ch09/birds/member_reg.php b/Ch09/birds/member_reg.php new file mode 100644 index 0000000..0a9adfe --- /dev/null +++ b/Ch09/birds/member_reg.php @@ -0,0 +1,329 @@ + + + + + Register Page + + + + + + + + + +
    + +
    + +
    + +
    +
    + + + + +
    +

    Register

    +

    Items marked with an asterisk * are required

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +'; + include('includes/info-col-cards.php'); + echo ''; + echo '
    '; + echo '
    '; + } + else + { + echo '
    '; + } + include('includes/footer.php'); + echo "
    "; + echo "
    "; + } +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + } + ?> + + diff --git a/Ch09/birds/mysqli_connect.php b/Ch09/birds/mysqli_connect.php new file mode 100644 index 0000000..d6ba870 --- /dev/null +++ b/Ch09/birds/mysqli_connect.php @@ -0,0 +1,11 @@ + + + + Pay With Check Page + + + + + + + + + + + +
    + +
    + +
    + +
    +
    + + + +
    +

    Complete your Registration by Paying with a Check

    +

    Thank you for registering online, now please fill out this +form. Asterisks indicate essential fields. When you +have filled out the form please print two copies by clicking the "Print This +Form" button. Sign one copy and keep one for reference, sign a check payable +to "The Devon Bird +Reserves".

    Mail the signed form and check to:
    The Treasurer, +The Devon Bird Reserves, +99 The Street, The Village, EX99 99ZZ

    +
    +
    + +


    +

    +

    +
    +


    +

    + Signed___________________________________________ Date_________________

    +
    +
    +
    +
    + +
    + + +
    + +
    + +
    +
    +
    + + diff --git a/Ch09/birds/print.css b/Ch09/birds/print.css new file mode 100644 index 0000000..fc221f9 --- /dev/null +++ b/Ch09/birds/print.css @@ -0,0 +1,10 @@ +/*PRINT.CSS: style amendments for printing only*/ +/*SELECT ITEMS THAT YOU DO NOT WANT TO PRINT, e.g., +header, menu, print-this-page button, and footer*/ +#header, #nav, #leftcol, #button, #rightcol, #footer, +#info-col, ul { display:none; } +input { border:1px black solid; } +h2 { font-size:16pt; color:black; text-align:center; } +h3 { text-align:center; font-size:11pt;} +/*REVEAL OUTGOING URL links on printed page*/ +a[href^="http://":after {content: "(" attr(href)")"; } \ No newline at end of file diff --git a/Ch09/birds/process-register-page.php b/Ch09/birds/process-register-page.php new file mode 100644 index 0000000..2161795 --- /dev/null +++ b/Ch09/birds/process-register-page.php @@ -0,0 +1,213 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password1trim = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); +$string_length = strlen($password1trim); +if (empty($password1trim)){ // #7 +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password1trim)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ +$password2trim = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); +if($password1trim === $password2trim) { // #9 +$password = $password1trim; +}else{ +$errors[] = 'Your two password do not match.'; +$errors[] = 'Please try again'; +} +} +} +//Is the 1st address present? If it is, sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only numeric, alphabetic, period, comma, dash and space. Max 30.'; + } +//If the 2nd address is present? If it is, sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z0-9\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_countrytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +$string_length = strlen($zcode_pcode); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + ($string_length <= 30) && ($string_length >= 5)) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the secret present? If it is, sanitize it +$secret = filter_var( $_POST['secret'], FILTER_SANITIZE_STRING); +if ((!empty($secret)) && (preg_match('/[a-z\.\s\,\-]/i', $secret)) && + (strlen($secret) <= 30)) { + //Sanitize the trimmed city + $secrettrim = $secret; + }else{ + $errors[] = 'Missing city. Only alphabetic, period, comma, dash and space. Max 30.'; + } +//Is the phone number present? If it is, sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } +//Is the class present? If it is, sanitize it +$class = filter_var( $_POST['level'], FILTER_SANITIZE_STRING); +if ((!empty($class)) && (strlen($class) <= 3)) { + //Sanitize the trimmed phone number + $classtrim = (filter_var($class, FILTER_SANITIZE_NUMBER_INT)); + }else{ + $errors[] = 'Missing Level Selection.'; + } +if (empty($errors)) { // If everything's OK. +// If no problems encountered, register user in the database +//Determine whether the email address has already been registered +$query = "SELECT userid FROM users WHERE email = ? "; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +mysqli_stmt_bind_param($q,'s', $emailtrim); +mysqli_stmt_execute($q); +$result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0){//The email address has not been registered +//already therefore register the user in the users table + //-------------Valid Entries - Save to database ----- + //Start of the SUCCESSFUL SECTION. i.e all the required fields were filled out + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + // Register the user in the database... + + $query = "INSERT INTO users (userid, title, first_name, last_name, email, password, class, "; + $query .= "address1, address2, city, state_country, zcode_pcode, phone, secret, registration_date) "; + $query .= "VALUES "; + $query .= "(' ',?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())"; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'sssssssssssss', + $titletrim, $first_nametrim, $last_nametrim, $emailtrim, $hashed_password, $classtrim, $address1trim, + $address2trim, $citytrim, $state_countrytrim, $zcode_pcodetrim, $phonetrim, $secrettrim); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + header ("location: register-thanks.php?class=" . $classtrim); + } else { + // echo 'Invalid query:' . $dbcon->error; + $errorstring = "System is busy, please try later"; + echo "

    $errorstring

    "; + } + }else{//The email address is already registered + $errorstring = 'The email address is already registered.'; + echo "

    $errorstring

    "; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +$errorstring = 'Error! The following error(s) occurred: '; +foreach ($errors as $msg) { // Print each error. +$errorstring .= " - $msg
    \n"; + } +$errorstring .= 'Please try again.'; +echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch09/birds/register-thanks.php b/Ch09/birds/register-thanks.php new file mode 100644 index 0000000..0631f66 --- /dev/null +++ b/Ch09/birds/register-thanks.php @@ -0,0 +1,165 @@ + + + + + Register Page + + + + + + + + + +
    + +
    + +
    + +
    +
    + + + +
    +

    Thank you for registering

    +
    To confirm your registration please verify membership class and pay the membership fee now.
    +
    You can use PayPal, a check or a credit/debit card.
    +

    When you have completed your registration you will be able to login +to the member's only pages.

    +Membership classes:' ; +echo '
    '; +for ($j = 0, $i = 0; $j < 5; $j++, $i = $i + 2) { + + echo $yearsarray[$j] . " £ " . + htmlspecialchars($row[$i], ENT_QUOTES) . + " GB, $ " . + htmlspecialchars($row[$i + 1], ENT_QUOTES) . + " US"; + + if ($j != 4) { + if ($j % 2 == 0) { echo "
    "; } + else { echo " , "; } + } +} +echo "
    "; +} +?> +

    +
    + + +
    + +
    + +
    +
    +
    +
    + +
    +
    + + + + + +
    +
    +
    +
    + + +
    + +
    + +
    +getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> + + diff --git a/Ch09/birds/reserves.php b/Ch09/birds/reserves.php new file mode 100644 index 0000000..5393922 --- /dev/null +++ b/Ch09/birds/reserves.php @@ -0,0 +1,115 @@ + + + + + Reserves Page + + + + + + + +
    + +
    + +
    + +
    +
    + + + +
    +

    The location and habitat of the Devon Bird Reserves

    +

    + + + + + + + + + + '; + } + echo '
    LocationLocation Type
    ' . $location . '' . $location_type . '
    '; // Close the table + mysqli_free_result ($result); // Free up the resources +} else { // If it did not run OK +// Message + echo '

    The current locations could not be retrieved. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; +} // End of if ($result) +mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?>

    +
    + + +
    + +
    + +
    +
    +
    + + diff --git a/Ch09/birds/verify.js b/Ch09/birds/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch09/birds/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch10/msgboarddb/cap.php b/Ch10/msgboarddb/cap.php new file mode 100644 index 0000000..201053b --- /dev/null +++ b/Ch10/msgboarddb/cap.php @@ -0,0 +1,17 @@ +Are you human? Click recaptcha"; + header( "refresh:1;" ); + } + } + else { echo "

    Are you human? Click recaptcha!

    "; + header( "refresh:1;" ); + } + +?> \ No newline at end of file diff --git a/Ch10/msgboarddb/forum.php b/Ch10/msgboarddb/forum.php new file mode 100644 index 0000000..e2365ec --- /dev/null +++ b/Ch10/msgboarddb/forum.php @@ -0,0 +1,46 @@ + + + + + Thank You Page + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Thanks for logging in. Choose a forum from the menu above.

    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/forum_c.php b/Ch10/msgboarddb/forum_c.php new file mode 100644 index 0000000..74895a7 --- /dev/null +++ b/Ch10/msgboarddb/forum_c.php @@ -0,0 +1,78 @@ + + + + + Message Board Home Page + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Comic Quotes

    + 0 ) +{ +?> + + + + + + + + + + + '; + } + echo '
    Posted ByForumQuotation
    ' . $user_name . '' . $post_date . '' . $message . '
    ' ; +} +else { echo 'There are currently no messages.' ; } +mysqli_close( $dbcon ) ; +?> +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/forum_w.php b/Ch10/msgboarddb/forum_w.php new file mode 100644 index 0000000..8788b1c --- /dev/null +++ b/Ch10/msgboarddb/forum_w.php @@ -0,0 +1,78 @@ + + + + + Message Board Home Page + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Wise Quotes

    + 0 ) +{ +?> + + + + + + + + + + + '; + } + echo '
    Posted ByForumQuotation
    ' . $user_name . '' . $post_date . '' . $message . '
    ' ; +} +else { echo 'There are currently no messages.' ; } +mysqli_close( $dbcon ) ; +?> +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/images/Thumbs.db b/Ch10/msgboarddb/images/Thumbs.db new file mode 100644 index 0000000..685af6f Binary files /dev/null and b/Ch10/msgboarddb/images/Thumbs.db differ diff --git a/Ch10/msgboarddb/includes/footer.php b/Ch10/msgboarddb/includes/footer.php new file mode 100644 index 0000000..6048dd8 --- /dev/null +++ b/Ch10/msgboarddb/includes/footer.php @@ -0,0 +1 @@ +

    Footer goes here

    \ No newline at end of file diff --git a/Ch10/msgboarddb/includes/header.php b/Ch10/msgboarddb/includes/header.php new file mode 100644 index 0000000..19eec49 --- /dev/null +++ b/Ch10/msgboarddb/includes/header.php @@ -0,0 +1,157 @@ + + + + + +
    +

    + +

    +
    + \ No newline at end of file diff --git a/Ch10/msgboarddb/index.php b/Ch10/msgboarddb/index.php new file mode 100644 index 0000000..c427c6a --- /dev/null +++ b/Ch10/msgboarddb/index.php @@ -0,0 +1,78 @@ + + + + + Message Board Home Page + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    This home page shows a selection from our large collection of quotations.

    +

    To view the whole collection, please register.

    +
    You will then be able to contribute to this message board by adding quotations.
    + 0 ) +{ +?> + + + + + + + + + + + '; + } + echo '
    Posted BySubjectMessage
    ' . $user_name . '' . $post_date . '' . $message . '
    ' ; +} +else { echo '

    There are currently no messages.

    ' ; } +mysqli_close( $dbcon ) ; +?> +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/login.php b/Ch10/msgboarddb/login.php new file mode 100644 index 0000000..085411d --- /dev/null +++ b/Ch10/msgboarddb/login.php @@ -0,0 +1,93 @@ + + + + + Login Page + + + + + + + + +
    + +
    + +
    + +
    +
    +
    + + +
    +

    + +

    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/logout.php b/Ch10/msgboarddb/logout.php new file mode 100644 index 0000000..b114a8e --- /dev/null +++ b/Ch10/msgboarddb/logout.php @@ -0,0 +1,18 @@ + + + + + Post A Quote Page + + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Post a Quotation

    + +
    +
    + +
    + +
    +
    +
    + +
    + + +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/post_thanks.php b/Ch10/msgboarddb/post_thanks.php new file mode 100644 index 0000000..ce093fd --- /dev/null +++ b/Ch10/msgboarddb/post_thanks.php @@ -0,0 +1,41 @@ + + + + + Thank You Page + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Thank you for Adding A Post.

    +
    Click on the Home Page to add or view more posts.
    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/process-login.php b/Ch10/msgboarddb/process-login.php new file mode 100644 index 0000000..5e355b0 --- /dev/null +++ b/Ch10/msgboarddb/process-login.php @@ -0,0 +1,103 @@ + 30))) { + $errors[] = 'You forgot to enter your User ID'; + $errors[] = ' or the User ID format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password = filter_var( $_POST['passcode'], FILTER_SANITIZE_STRING); +//$string_length = strlen($password); +if (empty($password)){ +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} +} + if (empty($errors)) { // If everything's OK. +// Retrieve the user_id, psword, first_name and user_level for that +// email/password combination + $query = "SELECT member_id, passcode, user_name FROM members "; + $query .= "WHERE user_name=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "s", $user_name); + + // execute query + + mysqli_stmt_execute($q); + +$result = mysqli_stmt_get_result($q); + +$row = mysqli_fetch_array($result, MYSQLI_NUM); +if (mysqli_num_rows($result) == 1) { +//if one database row (record) matches the input:- +// Start the session, fetch the record and insert the +// values in an array +if (password_verify($password, $row[1])) { +session_start(); +// Ensure that the user level is an integer. + $_SESSION[ 'member_id' ] = $row[0]; + $_SESSION[ 'user_name' ] = $row[2] ; + header ( 'Location: forum.php' ) ; +} else { // No password match was made. +$errors[] = 'User ID/Password entered does not match our records. '; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} else { // No e-mail match was made. +$errors[] = 'User ID/Password entered does not match our records. '; +$errors[] = 'Perhaps you need to register, just click the Register '; +$errors[] = 'button on the header menu'; +} +} +if (!empty($errors)) { + $errorstring = "Error!
    The following error(s) occurred:
    "; + foreach ($errors as $msg) { // Print each error. + $errorstring .= " $msg
    \n"; + } + $errorstring .= "Please try again.
    "; + }// End of if (!empty($errors)) IF. + +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +} // no else to allow user to enter values +?> \ No newline at end of file diff --git a/Ch10/msgboarddb/process-register-page.php b/Ch10/msgboarddb/process-register-page.php new file mode 100644 index 0000000..3ee75b5 --- /dev/null +++ b/Ch10/msgboarddb/process-register-page.php @@ -0,0 +1,129 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password1trim = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); +$string_length = strlen($password1trim); +if (empty($password1trim)){ // +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password1trim)) { // #8 +$errors[] = 'Invalid password, 8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ +$password2trim = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); +if($password1trim === $password2trim) { // +$password = $password1trim; +}else{ +$errors[] = 'Your two password do not match.'; +$errors[] = 'Please try again'; +} +} +} +//Is the secret present? If it is, sanitize it +$secret = filter_var( $_POST['secret'], FILTER_SANITIZE_STRING); +if ((!empty($secret)) && (preg_match('/[a-z\.\s\,\-]/i', $secret)) && + (strlen($secret) <= 30)) { + //Sanitize the trimmed city + $secrettrim = $secret; + }else{ + $errors[] = 'Missing city. Only alphabetic, period, comma, dash and space. Max 30.'; + } +if (empty($errors)) { // If everything's OK. +// If no problems encountered, register user in the database +//Determine whether the email address has already been registered +$query = "SELECT user_name FROM members WHERE email = ? "; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +mysqli_stmt_bind_param($q,'s', $emailtrim); +mysqli_stmt_execute($q); +$result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0){//The email address has not been registered +//already therefore register the user in the users table + //-------------Valid Entries - Save to database ----- + //Start of the SUCCESSFUL SECTION. i.e all the required fields were filled out + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + // Register the user in the database... + + // Register the user in the database... + $query = "INSERT INTO members (member_id, user_name, email, passcode, secret, reg_date) "; + $query .= "VALUES(' ', ?, ?, ?, ?, NOW() )"; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'ssss', $user_nametrim, $emailtrim, $hashed_password, $secrettrim); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + header ("location: register-thanks.php"); + } else { + // echo 'Invalid query:' . $dbcon->error; + $errorstring = "System is busy, please try later"; + echo "

    $errorstring

    "; + } + }else{//The email address is already registered + $errorstring = 'The email address is already registered.'; + echo "

    $errorstring

    "; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +$errorstring = 'Error! The following error(s) occurred: '; +foreach ($errors as $msg) { // Print each error. +$errorstring .= " - $msg
    \n"; + } +$errorstring .= 'Please try again.'; +echo "

    $errorstring

    "; + }// End of if (empty($errors)) IF. +} +catch(Exception $e) // We finally handle any problems here + { + // print "An Exception occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Exception Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Exception Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Exception Error \nFrom: Error Log ” . “\r\n”); + + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date(‘m.d.y h:i:s’); + // $errormessage = $e->getMessage(); + // $eMessage = $date . “ | Error | “ , $errormessage . |\n”; + // error_log($eMessage,3,ERROR_LOG); + // // e-mail support person to alert there is a problem + // error_log(“Date/Time: $date – Error, Check error log for +//details”, 1, noone@helpme.com, “Subject: Error \nFrom: Error Log ” . “\r\n”); + + } +?> \ No newline at end of file diff --git a/Ch10/msgboarddb/process_post.php b/Ch10/msgboarddb/process_post.php new file mode 100644 index 0000000..9707222 --- /dev/null +++ b/Ch10/msgboarddb/process_post.php @@ -0,0 +1,51 @@ + \ No newline at end of file diff --git a/Ch10/msgboarddb/quotes_found.php b/Ch10/msgboarddb/quotes_found.php new file mode 100644 index 0000000..3f30896 --- /dev/null +++ b/Ch10/msgboarddb/quotes_found.php @@ -0,0 +1,84 @@ + + + + + Search Page + + + + + + + +
    + +
    + +
    +
    + 0) { + echo '

    Full Text Search Results

    '; + ?> + + + + + + + + + + + '; + } + echo '
    Posted ByForumQuotation
    ' . $user_name . '' . $subject . '' . $message . '
    ' ; + } +else { echo '

    There are currently no messages.

    ' ; } +mysqli_close( $dbcon ) ; + } +?> +
    +
    +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/register-thanks.php b/Ch10/msgboarddb/register-thanks.php new file mode 100644 index 0000000..2bdf7df --- /dev/null +++ b/Ch10/msgboarddb/register-thanks.php @@ -0,0 +1,42 @@ + + + + + Thank You Page + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Thank you for registering

    +
    On the Home Page, you will now be able to login
    +
    and add new quotes to the message board.
    +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/safer-register-page.php b/Ch10/msgboarddb/safer-register-page.php new file mode 100644 index 0000000..26d7b83 --- /dev/null +++ b/Ch10/msgboarddb/safer-register-page.php @@ -0,0 +1,175 @@ + + + + + Register Page + + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Registration

    +

    Items marked with an asterisk * are required

    +
    IMPORTANT: Do NOT use your real name for the username.
    +
    Terms and conditions: Your registration and all your messages +will be immediately deleted
    +
    if you post unpleasant, obscene or defamatory messages to the message board.
    + + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +getMessage(); + print "The system is busy please try later"; + // $date = date('m.d.y h:i:s'); + // $errormessage = $e->getMessage(); + // $eMessage = $date . " | Exception Error | " , $errormessage . |\n"; + // error_log($eMessage,3,ERROR_LOG); +// e-mail support person to alert there is a problem + // error_log("Date/Time: $date – Exception Error, Check error log for +//details", 1, noone@helpme.com, "Subject: Exception Error \nFrom: +// Error Log " . "\r\n"); + } + catch(Error $e) + { + // print "An Error occurred. Message: " . $e->getMessage(); + print "The system is busy please try later"; + // $date = date('m.d.y h:i:s'); + // $errormessage = $e->getMessage(); + // $eMessage = $date . " | Error | " , $errormessage . |\n"; + // error_log($eMessage,3,ERROR_LOG); + // e-mail support person to alert there is a problem + // error_log("Date/Time: $date – Error, Check error log for +//details", 1, noone@helpme.com, "Subject: Error \nFrom: Error Log +// " . "\r\n"); + } + ?> + + \ No newline at end of file diff --git a/Ch10/msgboarddb/search.php b/Ch10/msgboarddb/search.php new file mode 100644 index 0000000..d0b3f1f --- /dev/null +++ b/Ch10/msgboarddb/search.php @@ -0,0 +1,64 @@ + + + + + Search Page + + + + + + + +
    + +
    + +
    + +
    +
    +
    +

    Search for a word or phrase in the quotes

    + +
    +
    +
    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch10/msgboarddb/verify.js b/Ch10/msgboarddb/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch10/msgboarddb/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch10/msgboarddb/view_posts.php b/Ch10/msgboarddb/view_posts.php new file mode 100644 index 0000000..810a257 --- /dev/null +++ b/Ch10/msgboarddb/view_posts.php @@ -0,0 +1,82 @@ + + + + + View Postings Page + + + + + + + +
    + +
    + +
    +
    + 0) { + echo '

    Your Postings

    '; + ?> + + + + + + + + + + + '; + } + echo '
    Posted ByForumQuotation
    ' . $user_name . " " . $post_date . '' . $subject . '' . $message . '
    ' ; + } +else { echo '

    There are currently no messages.

    ' ; } +mysqli_close( $dbcon ) ; +?> +
    +
    +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/added.php b/Ch11/Customcart/added.php new file mode 100644 index 0000000..467cbe8 --- /dev/null +++ b/Ch11/Customcart/added.php @@ -0,0 +1,77 @@ + + + + +The confirmation page + + + + + +
    +
    + +
    +
    +

    +Another one of those paintings has been added to your cart'; + } + else + { + // Add a different painting + $_SESSION['cart'][$id]= array ( 'quantity' => 1, 'price' => $row['price'] ) ; + echo '

    A painting has been added to your cart

    ' ; + } +} +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +// Close the database connection +mysqli_close($dbcon); +// Insert three lnks +echo '

    Continue Shopping | Checkout

    ' ; +?> +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/added1.php b/Ch11/Customcart/added1.php new file mode 100644 index 0000000..1624440 --- /dev/null +++ b/Ch11/Customcart/added1.php @@ -0,0 +1,89 @@ + + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + +
    +
    +

    +Another one of those paintings has been added to your cart'; + } + else + { + // Add a different painting + $_SESSION['cart'][$id]= array ( 'quantity' => 1, 'price' => $row['price'] ) ; + echo '

    A painting has been added to your cart

    ' ; + } +} +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +// Close the database connection +mysqli_close($dbcon); +// Insert three lnks +echo '

    Continue Shopping | Checkout

    ' ; +?> +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/admin_add_painting.php b/Ch11/Customcart/admin_add_painting.php new file mode 100644 index 0000000..ad43dfa --- /dev/null +++ b/Ch11/Customcart/admin_add_painting.php @@ -0,0 +1,193 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    + +
    +
    +The painting was successfully registered
    '; + } else { // If it was not registered + // Error message: + echo '

    System Error

    +

    The painting could not be added due to a system error. We apologize for any inconvenience.

    '; + // Debugging message: + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display the errors. + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Print each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if (empty($errors)) +} // End of the main Submit conditionals +?> +
    + +
    +

    Add a Painting

    +
    +

    + +

    +

    +
    +

    +
    +

    +
    +

    +

    +

    + +

    +

    +Figures only, no £s, $s or commas +

    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/admin_add_painting1.php b/Ch11/Customcart/admin_add_painting1.php new file mode 100644 index 0000000..db9e07d --- /dev/null +++ b/Ch11/Customcart/admin_add_painting1.php @@ -0,0 +1,131 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +

    Add a Painting

    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Figures only, no £s, $s or commas +
    +
    + +
    +
    + + +
    + +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/admin_form.css b/Ch11/Customcart/admin_form.css new file mode 100644 index 0000000..b48a509 --- /dev/null +++ b/Ch11/Customcart/admin_form.css @@ -0,0 +1,9 @@ +label { width:330px; float:left; text-align:right; } +select { width:200px; float:left; text-align:right; } +#submit { width:65px; margin-left:330px; margin-top:-10px; } +#content h2 { margin-left:-80px; top: 0px; width: 300px; } +input { margin-bottom:5px; } +#content h3 { text-align:center; width: 350px; margin-left:240px; } +html { height:100%; } +body { background:linear-gradient(green, #9ff781); height:100%; +} diff --git a/Ch11/Customcart/admin_page.css b/Ch11/Customcart/admin_page.css new file mode 100644 index 0000000..8439fde --- /dev/null +++ b/Ch11/Customcart/admin_page.css @@ -0,0 +1,13 @@ +#header-button { + position:absolute; top:10px; +} +#content h2 { margin-left:-220px; width:550px; } +#content h2.main_title { margin-left:-20px; width:250px; } +ul { margin-top:0; } +ul li { height:30px; } +p { margin-bottom:-5px; width:600px; } +form { margin-left:180px; } +#submit {margin-top:0; margin-left:215px; } +.cntr { text-align:center;} +p.error { color:red; font-size:105%; font-weight:bold; text-align:center;} +footer { margin-left:150px; } \ No newline at end of file diff --git a/Ch11/Customcart/admin_page.php b/Ch11/Customcart/admin_page.php new file mode 100644 index 0000000..5673a59 --- /dev/null +++ b/Ch11/Customcart/admin_page.php @@ -0,0 +1,124 @@ + + + + +Admin and add artist page + + + + + +
    +
    + +
    +
    +The artist was successfully added. Add another one?
    '; + } else { // If the query failed to run + // Message: + echo '

    System Error

    +

    The artist could not be added due to a system error. We apologize for any inconvenience.

    '; + // Debugging message: + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +} +catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display any errors + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Dispaly any errors + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if error checks +} // End of the conditionals +?> +
    + +
    +

    Add an Artist

    +

    If the artist uses only one name (e.g., Picasso) enter it as the last name

    +
    +

    +

    +

    +
    +

    +
    +
    + +

    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/admin_search.css b/Ch11/Customcart/admin_search.css new file mode 100644 index 0000000..0120a62 --- /dev/null +++ b/Ch11/Customcart/admin_search.css @@ -0,0 +1,7 @@ +h2.center { width:280px; margin-left:-70px; } +h3 { text-align:center; } +label { margin-left:150px; width:250px; float:left; text-align:right; } +#submit { margin-left:398px; } +html { height:100%; } +body { background:linear-gradient(green, #9ff781); height:100%; +} diff --git a/Ch11/Customcart/cart.php b/Ch11/Customcart/cart.php new file mode 100644 index 0000000..43218c1 --- /dev/null +++ b/Ch11/Customcart/cart.php @@ -0,0 +1,104 @@ + + + + +The view cart page + + + + + +
    +
    + +
    +
    +

    Items currently in your cart

    +

    + $item_qty ) + { +// Ensure that the id and the quantity are integers + $id = (int) $art_id; + $qty = (int) $item_qty; +// If the quantity is set to zero clear the session or else store the changed quantity + if ( $qty == 0 ) { unset ($_SESSION['cart'][$id]); } + elseif ( $qty > 0 ) { $_SESSION['cart'][$id]['quantity'] = $qty; } + } +} +// Set an initial variable for the total cost +$total = 0; +// Display the cart contents +if (!empty($_SESSION['cart'])) +{ + try { +// Connect to the database. + require ('mysqli_connect.php'); +// Get the items from the art table and insert them into the cart + $q = "SELECT * FROM art WHERE art_id IN ("; + foreach ($_SESSION['cart'] as $id => $value) { $q .= $id . ','; } + $q = substr( $q, 0, -1 ) . ') ORDER BY art_id ASC'; + $result = mysqli_query ($dbcon, $q); +// Create a form and a table + echo '

    + '; + while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) + { +// Calculate the subtotals and the grand total + $subtotal = $_SESSION['cart'][$row['art_id']]['quantity'] * $_SESSION['cart'][$row['art_id']]['price']; + $total += $subtotal; +// Display the table + echo " + + "; + } +// Close the database connection + mysqli_close($dbcon); +// Display the total + echo ' +
    {$row['type']}Painting(s)at {$row['price']} each ".number_format ($subtotal, 2)."
    Total = '.number_format($total,2).'
    +
    '; + } + catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +} +catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +} +else +// Or display a message +{ echo '

    Your cart is currently empty.

    ' ; } +// Create some links +echo '

    Continue Shopping | Checkout' ; +?> +

    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/checkout.php b/Ch11/Customcart/checkout.php new file mode 100644 index 0000000..23fe671 --- /dev/null +++ b/Ch11/Customcart/checkout.php @@ -0,0 +1,93 @@ + + + + +Checkout page + + + + +
    +
    + +
    +
    + +
    + 0 ) && (!empty($_SESSION['cart']) ) ) +{ + try { + // Connect to the database +require ( 'mysqli_connect.php' ) ; + // Insert the user's id, the total, and the order date into the orders table + + $query = "INSERT INTO orders ( user_id, total, order_date ) VALUES "; + $query .= "( ?, ?, NOW())"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'is', $_SESSION['user_id'],$_GET['total']); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + $order_id = mysqli_insert_id($dbcon); + // Get the selected paintings from the art table + $q = "SELECT * FROM art WHERE 'art_id' IN ("; + foreach ($_SESSION['cart'] as $id => $value) { $q .= $id . ','; } + $q = substr( $q, 0, -1 ) . ') ORDER BY price ASC'; + $result = mysqli_query ($dbcon, $q); +// Insert the order contents into the order_contents table + while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) + { + $query = "INSERT INTO order_contents ( order_id, art_id, quantity, price ) + VALUES ( $order_id, ".$row['art_id'].",".$_SESSION['cart'][$row['art_id']]['quantity'].",".$_SESSION['cart'][$row['art_id']]['price'].")" ; + $result = mysqli_query($dbcon,$query); + } + // Close the database connection + mysqli_close($dbcon); + // Display a thank you message and state the order number + echo "

    Thanks for your order. Your Order Number Is #".$order_id."

    "; + // Empty the cart ready for the next customer + $_SESSION['cart'] = NULL; +} + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +} +// Display a message +//else { echo '

    The shopping cart has been emptied ready for the next customer.

    ' ; } +?> +
    +
    +

    Thank you for your order. Your order number is 1906.

    +
    +

    The shopping cart has been emptied ready for your next +transaction.

    +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/added.php b/Ch11/Customcart/customcart/added.php new file mode 100644 index 0000000..bbec459 --- /dev/null +++ b/Ch11/Customcart/customcart/added.php @@ -0,0 +1,100 @@ + + + + + Added to Cart + + + + + + + +
    + +
    + +
    + +
    +
    + +
    +
    +

    +Another one of those paintings has been added to your cart'; + } + else + { + // Add a different painting + $_SESSION['cart'][$id]= array ( 'quantity' => 1, 'price' => $row['price'] ) ; + echo '

    A painting has been added to your cart

    ' ; + } +} +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Added | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Added Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Added Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Added | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Added Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Added Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +// Close the database connection +mysqli_close($dbcon); +// Insert three lnks +echo '

    Continue Shopping | Checkout

    ' ; +?> +
    + +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/admin_add_artist.php b/Ch11/Customcart/customcart/admin_add_artist.php new file mode 100644 index 0000000..53f70bd --- /dev/null +++ b/Ch11/Customcart/customcart/admin_add_artist.php @@ -0,0 +1,106 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add an Artist

    +
    If the artist uses only one name (e.g., Picasso) enter it as the last name
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/admin_add_painting.php b/Ch11/Customcart/customcart/admin_add_painting.php new file mode 100644 index 0000000..2c9a020 --- /dev/null +++ b/Ch11/Customcart/customcart/admin_add_painting.php @@ -0,0 +1,139 @@ + + + + + Add a Painting + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add a Painting

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Figures only, no £s, $s or commas +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/admin_page.php b/Ch11/Customcart/customcart/admin_page.php new file mode 100644 index 0000000..2c9a020 --- /dev/null +++ b/Ch11/Customcart/customcart/admin_page.php @@ -0,0 +1,139 @@ + + + + + Add a Painting + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add a Painting

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Figures only, no £s, $s or commas +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/cart.php b/Ch11/Customcart/customcart/cart.php new file mode 100644 index 0000000..dd03ed0 --- /dev/null +++ b/Ch11/Customcart/customcart/cart.php @@ -0,0 +1,59 @@ + + + + + View Cart + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    + +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/checkout.php b/Ch11/Customcart/customcart/checkout.php new file mode 100644 index 0000000..d85c6c9 --- /dev/null +++ b/Ch11/Customcart/customcart/checkout.php @@ -0,0 +1,63 @@ + + + + + Template for an interactive web page + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    +
    +

    Thank you for your order. Your order number is +.

    +
    The shopping cart has been emptied ready for your next +transaction.
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/customdb.sql b/Ch11/Customcart/customcart/customdb.sql new file mode 100644 index 0000000..f464c3d --- /dev/null +++ b/Ch11/Customcart/customcart/customdb.sql @@ -0,0 +1,273 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: May 28, 2018 at 08:36 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `customdb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `art` +-- + +CREATE TABLE `art` ( + `art_id` int(8) UNSIGNED NOT NULL, + `thumb` varchar(50) NOT NULL, + `type` varchar(50) NOT NULL, + `price` decimal(6,2) UNSIGNED NOT NULL, + `medium` varchar(50) NOT NULL, + `artist` varchar(50) NOT NULL, + `mini_descr` varchar(150) NOT NULL, + `ppcode` text NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `art` +-- + +INSERT INTO `art` (`art_id`, `thumb`, `type`, `price`, `medium`, `artist`, `mini_descr`, `ppcode`) VALUES +(1, '\"images/aw-brown-vessel-thumb.jpg\"', 'Still-life', '60.00', 'Oil-painting', 'Adrian-W-West', 'First exhibited in Coventry City Art Gallery 1968. Painted on durable tempered hardboard.', '

    \"\"

    '), +(2, '\"images/k-copper-kettle-thumb.jpg\"', 'Still-life', '750.00', 'Oil-painting', 'James-Kessell', 'James Kessell (RA and RABA) painted this on tempered hard board for an appreciative audience. It was exhibited at the Birmingham Art Gallery in 1967.', '

    \"\"

    '), +(3, '\"images/aw-white-jug-thumb.jpg\"', 'Still-life', '70.00', 'Oil-painting', 'Adrian-W-West', 'Painted on tempered hardboard in 1968 and exhibited first at Coventry City Art Gallery in the same year.', '

    \"\"

    '), +(4, '\"images/rsb-beer-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '), +(5, '\"images/rsb-blue-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Roger produces excellent etchings of Devon\'s native butterflies. ', '

    \"\"

    '), +(6, '\"images/rsb-fritillary-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'The silver washed fritillary is a less common Devon butterfly.', '

    \"\"

    '), +(7, '\"images/rsb-lyme-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(22, '\"images/rsb-lyme-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(23, '\"images/k-abstract-squares-thumb.jpg\"', 'Abstract', '800.00', 'Oil-painting', 'James-Kessell', 'Composition of squares and circles in tasteful pastel colors. Painted on high quality tempered board.', '

    \"\"

    '), +(21, '\"images/rsb-beer-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `artists` +-- + +CREATE TABLE `artists` ( + `artist_id` int(8) UNSIGNED NOT NULL, + `first_name` varchar(30) DEFAULT NULL, + `middle_name` varchar(30) DEFAULT NULL, + `last_name` varchar(30) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `artists` +-- + +INSERT INTO `artists` (`artist_id`, `first_name`, `middle_name`, `last_name`) VALUES +(1, 'Adrian', 'W', 'West'), +(2, 'Roger', 'St.', 'Barbe'), +(3, 'James', '', 'Kessell'), +(4, 'Charlie', 'S', 'Farnsbarns'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `orders` +-- + +CREATE TABLE `orders` ( + `order_id` int(8) UNSIGNED NOT NULL, + `buyer_id` int(8) UNSIGNED NOT NULL, + `total_price` decimal(7,2) NOT NULL, + `order_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_contents` +-- + +CREATE TABLE `order_contents` ( + `content_id` int(10) UNSIGNED NOT NULL, + `order_id` int(10) UNSIGNED NOT NULL, + `art_id` int(10) UNSIGNED NOT NULL, + `quantity` int(10) UNSIGNED NOT NULL DEFAULT '1', + `price` decimal(4,2) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `order_contents` +-- + +INSERT INTO `order_contents` (`content_id`, `order_id`, `art_id`, `quantity`, `price`) VALUES +(1, 2, 4, 1, '17.99'), +(2, 3, 4, 1, '17.99'), +(3, 4, 2, 1, '14.99'), +(4, 5, 3, 1, '16.99'), +(5, 6, 1, 1, '19.99'), +(6, 7, 1, 1, '60.00'), +(7, 8, 2, 1, '99.99'), +(8, 15, 1, 1, '60.00'), +(9, 16, 1, 1, '60.00'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_details` +-- + +CREATE TABLE `order_details` ( + `ord_details_id` int(8) UNSIGNED NOT NULL, + `order_id` int(8) UNSIGNED NOT NULL, + `art_id` int(8) UNSIGNED NOT NULL, + `dispatch_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `user_id` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `address1` varchar(50) NOT NULL, + `address2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `secret` varchar(30) NOT NULL, + `user_level` int(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`user_id`, `title`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `secret`, `user_level`) VALUES +(1, 'Mr', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UiiBhmXca.0/bwopveFq8uInuX.EVrecinUQYQG546WjAWwZLJNoe', '2017-12-06 08:43:41', '4 The Street', 'The Village', 'Townsville', 'USA', 'WA', '0123777888', '', 0), +(2, 'Mr', 'Jack', 'Smith', 'jsmith@outcook.com', '44fc2837cca3d8994cba9d02d94a15c1fe7b1d66', '2017-12-06 08:47:24', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(4, 'Ms', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$5KM8jy5MwHIgfVchsdfE8OvuF1cT2VYqU6mte2CWBw1HjmEv3r.ES', '2017-12-06 12:20:33', '6 The Street', '', 'Townsville', 'UK', 'EX9 9PG', '01234777888', '', 0), +(5, 'Mr', 'Patrick', 'O\'Hara', 'pohara@myisp.org.uk', '$2y$10$0nmGDVmHdWusgFJRmVZADeL43Y7HCPViBrHj/Z2betxiMdMx5Y2sC', '2017-12-06 12:27:32', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(6, 'Mr', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$KCQhEftEJouWPfuOOVoRVOECY/oJTluxHRr85fWlz6nsfN4OHtCie', '2017-12-06 17:02:16', '6 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PS', '', '', 0), +(7, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$IrQE3TTkWzNm93FP/VYf.O/yMWDJDpIn/.qjrmvN.I97fvakynuza', '2017-12-06 17:11:44', '7 The Street', 'The Village', 'Townsville', 'UK', 'EXP 6PG', '01234777888', '', 0), +(8, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$R2auBMKMe/Qw2fFr8D.S8eUEENUz8r.YUth5NHAyskNYupUzBen5O', '2017-12-06 17:18:30', '7 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(9, 'Mrs', 'Annie', 'Mossity', 'amossity@myisp.org.uk', '$2y$10$amqmyEfaOfiZ0MkIzdO90uZMPw4Mi/4RR70nNd0nxaZSOlxlr.8DC', '2017-12-06 17:24:42', '4 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '', 0), +(10, 'Mr', 'Percy', 'Veer', 'pveer@myisp.com', '$2y$10$Wvdx/YO4cCcOQvyMVVtapO3F/eiz2Ow3yU9VcczGMC.dcgwbgIXMS', '2017-12-06 17:28:53', '7 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '', 0), +(11, 'Mr', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$cTmJVcuUmTpCOIdQJ8MG3uwLmG7M7V3iE8zPXiNW2PQEdDQZMBftO', '2017-12-06 17:39:30', '5 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(12, 'Mr', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$YUYnU8UvOF/WUJ5h4VK4Qe.I48ZcAbedjPiDekKHlODduqGdJoI9i', '2017-12-06 18:02:04', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '', 0), +(13, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$k9sMvE001164jjzJLs.OpOmb9LtluUEbR4GQ4RT5/rvSPNIqbL6gC', '2017-12-07 17:39:34', '6 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(14, 'Mr', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$TOr.IZq/joHIKSk0Oo.jE.yWau48sUSgtC5TzKJ0sl0AoO2Bsk3lW', '2017-12-08 12:16:58', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '', 0), +(16, 'Miss', 'Lynn', 'Seed', 'lseed@myisp.com', '$2y$10$nEs3Zhh4V5ZznpcPzGs9gOWupjY2NgV87DPpLu2DjqsdyBNRjf4/C', '2017-12-16 20:03:16', '6 The Street', '', 'Townsville', 'UK', 'EX24 6PG', '01234777888', '', 0), +(17, 'Mr', 'Barry', 'Tone', 'btone@myisp.net', '$2y$10$w4zMq7ij7NmVDeBBKDSmbu963EwchZwAHPZmgZmTQAQ8Gha2jTD5W', '2017-12-16 20:16:40', '2 The Street', '', 'Townsville', 'USA', 'CA12345', '', '', 0), +(30, 'Mr', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$lePdxFz7ZKn/bJ41BS0h/ehWyIL2ZgK123iPQJahNCaRjgxVY3Rfq', '2017-12-29 11:28:43', '2 The Street', 'The Village', 'Townsville', 'Germany', 'BL1234', '', '', 0), +(31, 'Miss', 'Dee', 'Jected', 'djected@myisp.org.uk', '$2y$10$ujpV7w4blsTdQFWOsE1fiOFYtj9zN4w0WcK5V4WJ60Pc5HWodWlGC', '2017-12-29 11:48:04', '3 The Street', 'The Village', 'Townsville', 'UK', 'EX3 1TH', '', '', 0), +(32, 'Mr', 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$Yu.c/cw/TSFa9vcMBGAfAe5vzyOwp3SZarBVc/9vEksfp.F8BzSiW', '2017-12-29 11:58:51', '2 The Street', '', 'Townsville', 'UK', 'EX24 6PS', '01234777888', '', 0), +(40, NULL, 'Stuff', 'Stuff', 'stuff@stuff.com', '$2y$10$5D9RsKOqA/hr/Z.7ko/.M.ngQSqWDzOfnu7OhUnBLzxXwKVxHk6YW', '2018-05-25 16:52:54', '121 sd', NULL, 'fh', 'dj', '33333', '1233333333', 'dfd', 1), +(41, NULL, 'xx', 'xx', 'ccc@ccc.com', '$2y$10$dxTlEJ82C3g99CUmSuUWbOFyg8CT42jFhz.cgHqrkMhqxyIajbgKi', '2018-05-27 10:00:33', '44 as', NULL, 'kl', 'kl', '33333', NULL, 'fred', 0), +(42, NULL, 'Mx', 'asaa', 'mmm@mmm.com', '$2y$10$7iVu8Thd3ZEBTu0.aRtud.6qNtplrJ/jembAUcfEFwczEN42PkFii', '2018-05-27 10:02:28', '123 as', NULL, 'kw', 'fl', '33333', NULL, 'fred', 0); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `art` +-- +ALTER TABLE `art` + ADD PRIMARY KEY (`art_id`), + ADD KEY `art_name` (`thumb`,`price`); + +-- +-- Indexes for table `artists` +-- +ALTER TABLE `artists` + ADD PRIMARY KEY (`artist_id`); + +-- +-- Indexes for table `orders` +-- +ALTER TABLE `orders` + ADD PRIMARY KEY (`order_id`), + ADD KEY `buyer_id` (`buyer_id`,`order_date`); + +-- +-- Indexes for table `order_contents` +-- +ALTER TABLE `order_contents` + ADD PRIMARY KEY (`content_id`); + +-- +-- Indexes for table `order_details` +-- +ALTER TABLE `order_details` + ADD PRIMARY KEY (`ord_details_id`), + ADD KEY `order_id` (`order_id`,`art_id`,`dispatch_date`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`user_id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `art` +-- +ALTER TABLE `art` + MODIFY `art_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31; + +-- +-- AUTO_INCREMENT for table `artists` +-- +ALTER TABLE `artists` + MODIFY `artist_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=50; + +-- +-- AUTO_INCREMENT for table `orders` +-- +ALTER TABLE `orders` + MODIFY `order_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `order_contents` +-- +ALTER TABLE `order_contents` + MODIFY `content_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; + +-- +-- AUTO_INCREMENT for table `order_details` +-- +ALTER TABLE `order_details` + MODIFY `ord_details_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `user_id` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=43; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch11/Customcart/customcart/forgot.php b/Ch11/Customcart/customcart/forgot.php new file mode 100644 index 0000000..24bff3c --- /dev/null +++ b/Ch11/Customcart/customcart/forgot.php @@ -0,0 +1,89 @@ + + + + + Forgot Password + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Forgot Your Password?

    +
    When you apply, you will receive your new password in an email. Read that +email as soon as possible. Don't delay! For +maximum security, immediately login with your new password. Then change the +password as quickly as possible.
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + + If you don't know your secret answer, contact our service department. +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/found_pics_cart.php b/Ch11/Customcart/customcart/found_pics_cart.php new file mode 100644 index 0000000..f8ee5f7 --- /dev/null +++ b/Ch11/Customcart/customcart/found_pics_cart.php @@ -0,0 +1,60 @@ + + + + + Paintings Found + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +

    To buy a painting please click its Add to Cart link

    + +

    No paintings displayed? Either we have nothing that matches +your requirements at the moment OR you may have forgotten to select +BOTH the search fields. Please click the Find Pictures button and try again.

    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/images/L-looking-back-a-beer.jpg b/Ch11/Customcart/customcart/images/L-looking-back-a-beer.jpg new file mode 100644 index 0000000..bf6152f Binary files /dev/null and b/Ch11/Customcart/customcart/images/L-looking-back-a-beer.jpg differ diff --git a/Ch11/Customcart/customcart/images/L-silver-studded-blue.jpg b/Ch11/Customcart/customcart/images/L-silver-studded-blue.jpg new file mode 100644 index 0000000..c45da2f Binary files /dev/null and b/Ch11/Customcart/customcart/images/L-silver-studded-blue.jpg differ diff --git a/Ch11/Customcart/customcart/images/Thumbs.db b/Ch11/Customcart/customcart/images/Thumbs.db new file mode 100644 index 0000000..faaaabf Binary files /dev/null and b/Ch11/Customcart/customcart/images/Thumbs.db differ diff --git a/Ch11/Customcart/customcart/images/aw-brown-vessel-200.jpg b/Ch11/Customcart/customcart/images/aw-brown-vessel-200.jpg new file mode 100644 index 0000000..df6dde2 Binary files /dev/null and b/Ch11/Customcart/customcart/images/aw-brown-vessel-200.jpg differ diff --git a/Ch11/Customcart/customcart/images/aw-brown-vessel-thumb.jpg b/Ch11/Customcart/customcart/images/aw-brown-vessel-thumb.jpg new file mode 100644 index 0000000..26dcaa5 Binary files /dev/null and b/Ch11/Customcart/customcart/images/aw-brown-vessel-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/aw-brown-vessel.jpg b/Ch11/Customcart/customcart/images/aw-brown-vessel.jpg new file mode 100644 index 0000000..8f62c17 Binary files /dev/null and b/Ch11/Customcart/customcart/images/aw-brown-vessel.jpg differ diff --git a/Ch11/Customcart/customcart/images/aw-white-jug-home.jpg b/Ch11/Customcart/customcart/images/aw-white-jug-home.jpg new file mode 100644 index 0000000..8f92b65 Binary files /dev/null and b/Ch11/Customcart/customcart/images/aw-white-jug-home.jpg differ diff --git a/Ch11/Customcart/customcart/images/aw-white-jug-thumb.jpg b/Ch11/Customcart/customcart/images/aw-white-jug-thumb.jpg new file mode 100644 index 0000000..426d3df Binary files /dev/null and b/Ch11/Customcart/customcart/images/aw-white-jug-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/aw-white-jug.jpg b/Ch11/Customcart/customcart/images/aw-white-jug.jpg new file mode 100644 index 0000000..d0d8f25 Binary files /dev/null and b/Ch11/Customcart/customcart/images/aw-white-jug.jpg differ diff --git a/Ch11/Customcart/customcart/images/cart.jpg b/Ch11/Customcart/customcart/images/cart.jpg new file mode 100644 index 0000000..27213e0 Binary files /dev/null and b/Ch11/Customcart/customcart/images/cart.jpg differ diff --git a/Ch11/Customcart/customcart/images/dove-1.png b/Ch11/Customcart/customcart/images/dove-1.png new file mode 100644 index 0000000..69a4410 Binary files /dev/null and b/Ch11/Customcart/customcart/images/dove-1.png differ diff --git a/Ch11/Customcart/customcart/images/green-grad-800.jpg b/Ch11/Customcart/customcart/images/green-grad-800.jpg new file mode 100644 index 0000000..696ad2b Binary files /dev/null and b/Ch11/Customcart/customcart/images/green-grad-800.jpg differ diff --git a/Ch11/Customcart/customcart/images/home.jpg b/Ch11/Customcart/customcart/images/home.jpg new file mode 100644 index 0000000..002c2c4 Binary files /dev/null and b/Ch11/Customcart/customcart/images/home.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-abstract-squares-thumb.jpg b/Ch11/Customcart/customcart/images/k-abstract-squares-thumb.jpg new file mode 100644 index 0000000..80362b7 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-abstract-squares-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-abstract-thumb.jpg b/Ch11/Customcart/customcart/images/k-abstract-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-abstract-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-copper-kettle-300.jpg b/Ch11/Customcart/customcart/images/k-copper-kettle-300.jpg new file mode 100644 index 0000000..7bbaf16 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-copper-kettle-300.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-copper-kettle-home.jpg b/Ch11/Customcart/customcart/images/k-copper-kettle-home.jpg new file mode 100644 index 0000000..957e09d Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-copper-kettle-home.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-copper-kettle-thumb.jpg b/Ch11/Customcart/customcart/images/k-copper-kettle-thumb.jpg new file mode 100644 index 0000000..27ca9f7 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-copper-kettle-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-stil-life-2.jpg b/Ch11/Customcart/customcart/images/k-stil-life-2.jpg new file mode 100644 index 0000000..f22b330 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-stil-life-2.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-stil-life-3.jpg b/Ch11/Customcart/customcart/images/k-stil-life-3.jpg new file mode 100644 index 0000000..7e92b77 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-stil-life-3.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-stil-life-thumb.jpg b/Ch11/Customcart/customcart/images/k-stil-life-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-stil-life-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/k-still-life-thumb.jpg b/Ch11/Customcart/customcart/images/k-still-life-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/Customcart/customcart/images/k-still-life-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/L-looking-back-a-beer.jpg b/Ch11/Customcart/customcart/images/large files/L-looking-back-a-beer.jpg new file mode 100644 index 0000000..bf6152f Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/L-looking-back-a-beer.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/L-silver-studded-blue.jpg b/Ch11/Customcart/customcart/images/large files/L-silver-studded-blue.jpg new file mode 100644 index 0000000..c45da2f Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/L-silver-studded-blue.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/L-silver-washed=fritillary.jpg b/Ch11/Customcart/customcart/images/large files/L-silver-washed=fritillary.jpg new file mode 100644 index 0000000..9067c77 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/L-silver-washed=fritillary.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/Thumbs.db b/Ch11/Customcart/customcart/images/large files/Thumbs.db new file mode 100644 index 0000000..b80fb46 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/Thumbs.db differ diff --git a/Ch11/Customcart/customcart/images/large files/aw-brown-vessel-200.jpg b/Ch11/Customcart/customcart/images/large files/aw-brown-vessel-200.jpg new file mode 100644 index 0000000..df6dde2 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/aw-brown-vessel-200.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/aw-brown-vessel.jpg b/Ch11/Customcart/customcart/images/large files/aw-brown-vessel.jpg new file mode 100644 index 0000000..8f62c17 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/aw-brown-vessel.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/aw-white-jug-200.jpg b/Ch11/Customcart/customcart/images/large files/aw-white-jug-200.jpg new file mode 100644 index 0000000..87f6c8a Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/aw-white-jug-200.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/aw-white-jug-home.jpg b/Ch11/Customcart/customcart/images/large files/aw-white-jug-home.jpg new file mode 100644 index 0000000..35425ca Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/aw-white-jug-home.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/aw-white-jug.jpg b/Ch11/Customcart/customcart/images/large files/aw-white-jug.jpg new file mode 100644 index 0000000..d0d8f25 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/aw-white-jug.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/k-copper-kettle-380.jpg b/Ch11/Customcart/customcart/images/large files/k-copper-kettle-380.jpg new file mode 100644 index 0000000..e1c21f0 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/k-copper-kettle-380.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/k-stil-life-2.jpg b/Ch11/Customcart/customcart/images/large files/k-stil-life-2.jpg new file mode 100644 index 0000000..f22b330 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/k-stil-life-2.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/k-stil-life-3.jpg b/Ch11/Customcart/customcart/images/large files/k-stil-life-3.jpg new file mode 100644 index 0000000..7e92b77 Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/k-stil-life-3.jpg differ diff --git a/Ch11/Customcart/customcart/images/large files/k-stil-life-300.jpg b/Ch11/Customcart/customcart/images/large files/k-stil-life-300.jpg new file mode 100644 index 0000000..01bbc4f Binary files /dev/null and b/Ch11/Customcart/customcart/images/large files/k-stil-life-300.jpg differ diff --git a/Ch11/Customcart/customcart/images/prints.jpg b/Ch11/Customcart/customcart/images/prints.jpg new file mode 100644 index 0000000..01a7209 Binary files /dev/null and b/Ch11/Customcart/customcart/images/prints.jpg differ diff --git a/Ch11/Customcart/customcart/images/rsb-beer-thumb.jpg b/Ch11/Customcart/customcart/images/rsb-beer-thumb.jpg new file mode 100644 index 0000000..196ca9c Binary files /dev/null and b/Ch11/Customcart/customcart/images/rsb-beer-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/rsb-blue-thumb.jpg b/Ch11/Customcart/customcart/images/rsb-blue-thumb.jpg new file mode 100644 index 0000000..fe2b0c9 Binary files /dev/null and b/Ch11/Customcart/customcart/images/rsb-blue-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/rsb-fritillary-thumb.jpg b/Ch11/Customcart/customcart/images/rsb-fritillary-thumb.jpg new file mode 100644 index 0000000..1ea329f Binary files /dev/null and b/Ch11/Customcart/customcart/images/rsb-fritillary-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/rsb-lyme-thumb.jpg b/Ch11/Customcart/customcart/images/rsb-lyme-thumb.jpg new file mode 100644 index 0000000..ddb1800 Binary files /dev/null and b/Ch11/Customcart/customcart/images/rsb-lyme-thumb.jpg differ diff --git a/Ch11/Customcart/customcart/images/title.jpg b/Ch11/Customcart/customcart/images/title.jpg new file mode 100644 index 0000000..5e38df9 Binary files /dev/null and b/Ch11/Customcart/customcart/images/title.jpg differ diff --git a/Ch11/Customcart/customcart/images/unavailable.png b/Ch11/Customcart/customcart/images/unavailable.png new file mode 100644 index 0000000..41374c4 Binary files /dev/null and b/Ch11/Customcart/customcart/images/unavailable.png differ diff --git a/Ch11/Customcart/customcart/includes/footer.php b/Ch11/Customcart/customcart/includes/footer.php new file mode 100644 index 0000000..6f56f56 --- /dev/null +++ b/Ch11/Customcart/customcart/includes/footer.php @@ -0,0 +1 @@ +

    Footer goes here

    \ No newline at end of file diff --git a/Ch11/Customcart/customcart/includes/header.php b/Ch11/Customcart/customcart/includes/header.php new file mode 100644 index 0000000..cc291fb --- /dev/null +++ b/Ch11/Customcart/customcart/includes/header.php @@ -0,0 +1,117 @@ + + + + +
    +dove +
    +
    +
    The Dove Gallery
    +

    Affordable Original Paintings

    +
    + +
    + +
    \ No newline at end of file diff --git a/Ch11/Customcart/customcart/includes/menu.php b/Ch11/Customcart/customcart/includes/menu.php new file mode 100644 index 0000000..5f44ec0 --- /dev/null +++ b/Ch11/Customcart/customcart/includes/menu.php @@ -0,0 +1,27 @@ + + + +
    + +
    \ No newline at end of file diff --git a/Ch11/Customcart/customcart/index.php b/Ch11/Customcart/customcart/index.php new file mode 100644 index 0000000..dd8e55e --- /dev/null +++ b/Ch11/Customcart/customcart/index.php @@ -0,0 +1,64 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    +
    +

    Welcome to the Dove Gallery

    +
    To search the gallery, please register and log in
    +

    +Brown Jug by Adrian West +L-Silver washed blue +White Jug +

    +
    + +
    +
    +
    +
    +Copper kettle +Looking Back at Beer +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/login-files/login.php b/Ch11/Customcart/customcart/login-files/login.php new file mode 100644 index 0000000..640deaf --- /dev/null +++ b/Ch11/Customcart/customcart/login-files/login.php @@ -0,0 +1,47 @@ + + + +Login page + + + + + +
    +
    +
    + +
    +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +

    Login

    +
    +

    +

    +

    +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/login-files/login_functions.php b/Ch11/Customcart/customcart/login-files/login_functions.php new file mode 100644 index 0000000..7bc1283 --- /dev/null +++ b/Ch11/Customcart/customcart/login-files/login_functions.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/login.php b/Ch11/Customcart/customcart/login.php new file mode 100644 index 0000000..0c00087 --- /dev/null +++ b/Ch11/Customcart/customcart/login.php @@ -0,0 +1,93 @@ + + + + + Login Page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +
    +
    + +
    +

    Login

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/login_functions.php b/Ch11/Customcart/customcart/login_functions.php new file mode 100644 index 0000000..88ee47e --- /dev/null +++ b/Ch11/Customcart/customcart/login_functions.php @@ -0,0 +1,76 @@ +getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Login | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Login Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Login Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } + // Retrieve the error messages + return array( false, $errors ) ; +} \ No newline at end of file diff --git a/Ch11/Customcart/customcart/login_toolss.php b/Ch11/Customcart/customcart/login_toolss.php new file mode 100644 index 0000000..b634d7f --- /dev/null +++ b/Ch11/Customcart/customcart/login_toolss.php @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/mysqli_connect.php b/Ch11/Customcart/customcart/mysqli_connect.php new file mode 100644 index 0000000..26eb5ed --- /dev/null +++ b/Ch11/Customcart/customcart/mysqli_connect.php @@ -0,0 +1,12 @@ +The painting was successfully registered
    '; + } else { // If it was not registered + // Error message: + echo '

    System Error

    +

    The painting could not be added due to a system error. We apologize for any inconvenience.

    '; + // Debugging message: + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Add Painting | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Add Painting Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Add Painting Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Add Painting | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Add Painting Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Add Painting Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display the errors. + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Print each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if (empty($errors)) +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcart/process_admin_page.php b/Ch11/Customcart/customcart/process_admin_page.php new file mode 100644 index 0000000..9e83197 --- /dev/null +++ b/Ch11/Customcart/customcart/process_admin_page.php @@ -0,0 +1,91 @@ +The artist was successfully added.'; + } else { // If the query failed to run + // Message: + echo '

    System Error

    +

    The artist could not be added due to a system error. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Admin Page | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Admin Page Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Admin Page Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Admin Page | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Admin Page Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Admin Page Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display any errors + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Display any errors + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if error checks +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcart/process_cart.php b/Ch11/Customcart/customcart/process_cart.php new file mode 100644 index 0000000..448bcf7 --- /dev/null +++ b/Ch11/Customcart/customcart/process_cart.php @@ -0,0 +1,85 @@ + $item_qty ) + { +// Ensure that the id and the quantity are integers + $id = (int) $art_id; + $qty = (int) $item_qty; +// If the quantity is set to zero clear the session or else store the changed quantity + if ( $qty == 0 ) { unset ($_SESSION['cart'][$id]); } + elseif ( $qty > 0 ) { $_SESSION['cart'][$id]['quantity'] = $qty; } + } + } +// Set an initial variable for the total cost +$total = 0; +// Display the cart contents +if (!empty($_SESSION['cart'])) +{ +?> +
    + +
    +
    + $value) { $q .= $id . ','; } + $q = substr( $q, 0, -1 ) . ') ORDER BY art_id ASC'; + $result = mysqli_query ($dbcon, $q); +// Create a form and a table + echo '
    '; + echo ''; + echo ''; + echo ''; + echo ''; + while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) + { +// Calculate the subtotals and the grand total + $subtotal = $_SESSION['cart'][$row['art_id']]['quantity'] * $_SESSION['cart'][$row['art_id']]['price']; + $total += $subtotal; +// Display the table + echo " + + "; + } +// Close the database connection + mysqli_close($dbcon); +// Display the total + echo ' +
    MediumTypeQuantityPrice
    {$row['type']}Painting(s)at {$row['price']} each ".number_format ($subtotal, 2)."
    Total = '.number_format($total,2).'
    '; + echo '
    '; + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Cart | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Cart Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Cart Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Cart | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Cart Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Cart Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +echo "
    "; +echo "
    "; +} +else +// Or display a message +{ echo '

    Your cart is currently empty.

    ' ; +} +// Create some links +echo '

    Continue Shopping | Checkout' ; +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcart/process_checkout.php b/Ch11/Customcart/customcart/process_checkout.php new file mode 100644 index 0000000..dd7eefa --- /dev/null +++ b/Ch11/Customcart/customcart/process_checkout.php @@ -0,0 +1,55 @@ + 0 ) && (!empty($_SESSION['cart']) ) ) +{ + try { + // Connect to the database +require ( 'mysqli_connect.php' ) ; + // Insert the user's id, the total, and the order date into the orders table + + $query = "INSERT INTO orders ( user_id, total, order_date ) VALUES "; + $query .= "( ?, ?, NOW())"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'is', $_SESSION['user_id'],$_GET['total']); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + $order_id = mysqli_insert_id($dbcon); + // Get the selected paintings from the art table + $q = "SELECT * FROM art WHERE 'art_id' IN ("; + foreach ($_SESSION['cart'] as $id => $value) { $q .= $id . ','; } + $q = substr( $q, 0, -1 ) . ') ORDER BY price ASC'; + $result = mysqli_query ($dbcon, $q); +// Insert the order contents into the order_contents table + while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) + { + $query = "INSERT INTO order_contents ( order_id, art_id, quantity, price ) + VALUES ( $order_id, ".$row['art_id'].",".$_SESSION['cart'][$row['art_id']]['quantity'].",".$_SESSION['cart'][$row['art_id']]['price'].")" ; + $result = mysqli_query($dbcon,$query); + } + // Close the database connection + mysqli_close($dbcon); + // Display a thank you message and state the order number + // Empty the cart ready for the next customer + $_SESSION['cart'] = NULL; +} + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +} +// Display a message +//else { echo '

    The shopping cart has been emptied ready for the next customer.

    ' ; } +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcart/process_forgot.php b/Ch11/Customcart/customcart/process_forgot.php new file mode 100644 index 0000000..ea204cc --- /dev/null +++ b/Ch11/Customcart/customcart/process_forgot.php @@ -0,0 +1,75 @@ +If your e-mail and secret are correct, you will recieve an e-mail'; + } + } + if ($buyid) { // If buyid for the email address was retrieved, create a random password + $password = substr ( md5(uniqid(rand(), true)), 5, 10); +// Update the database table + $hassed_password = password_hash($password, PASSWORD_DEFAULT); + $query = "UPDATE users SET password=? WHERE user_id=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "si", $hassed_password, $buyid); + // execute query + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { +// Send an email to the buyer + $body = "Your password has been changed to '" . $password; + $body .= "'. Please login as soon as possible using the new password. "; + $body .= "Then change it immediately. otherwise, if a hacker has intercepted "; + $body .= "this email they will know your login details."; + mail ($_POST['email'], 'Your new password.', $body, 'From: admin@thedovegallery.co.uk'); +// Echo a message and exit the code + echo '
    Your password has been changed. '; + echo 'You will shortly receive the new temporary password by email.
    '; + mysqli_close($dbcon); + include ('includes/footer.php'); + exit(); // Stop the script. + } else { // If the query failed to run + echo '

    Due to a system error, your password could not be changed. We apologize for any inconvenience.

    '; + } + } + mysqli_close($dbcon); + } + catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Forgot Password | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Forgot Password Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Forgot Password Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Forgot Password | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Forgot Password Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Forgot Password Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcart/process_found_pics.php b/Ch11/Customcart/customcart/process_found_pics.php new file mode 100644 index 0000000..247316d --- /dev/null +++ b/Ch11/Customcart/customcart/process_found_pics.php @@ -0,0 +1,73 @@ + 0) { + +//$result = mysqli_query( $dbcon, $q ) ; +//if ( mysqli_num_rows( $result ) > 0 ) +//{ +// Table header +?> + + + + + + + + + + + + + '; + } +?> +
    ThumbTypeMediumArtistDetailsPrice £
    ' . $row['type'] . '' . $row['medium'] . '' . $row['artist'] . '' . $row['mini_descr'] . '' . $row['price'] . + '
    Add to Cart
    +There are currently no items matching your search criteria.

    ' ; } +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Found Pics | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Found Pics Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Found Pics Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Found Pics | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Found Pics Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Found Pics Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcart/process_login.php b/Ch11/Customcart/customcart/process_login.php new file mode 100644 index 0000000..459f34e --- /dev/null +++ b/Ch11/Customcart/customcart/process_login.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/process_register.php b/Ch11/Customcart/customcart/process_register.php new file mode 100644 index 0000000..3371c4b --- /dev/null +++ b/Ch11/Customcart/customcart/process_register.php @@ -0,0 +1,197 @@ +error; +// change to generic message in production + } + }else{//The email address is already registered +echo '

    The email address is already registered

    '; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +echo '

    Error!

    +

    The following error(s) occurred:
    '; +foreach ($errors as $msg) { // Print each error. +echo " - $msg
    \n"; + } +echo '

    Please try again.


    '; + }// End of if (empty($errors)) IF. +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Registration | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Register Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Register Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Registration | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Register Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Register Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcart/register.php b/Ch11/Customcart/customcart/register.php new file mode 100644 index 0000000..3ad26c6 --- /dev/null +++ b/Ch11/Customcart/customcart/register.php @@ -0,0 +1,210 @@ + + + + + Template for an interactive web page + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Account Registration

    +
    Items marked with an asterisk * are essential
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/register_thanks.php b/Ch11/Customcart/customcart/register_thanks.php new file mode 100644 index 0000000..9576943 --- /dev/null +++ b/Ch11/Customcart/customcart/register_thanks.php @@ -0,0 +1,38 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    +

    Thank you for registering

    +
    You will now be able to login, search for, and view the paintings.
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcart/transparent.css b/Ch11/Customcart/customcart/transparent.css new file mode 100644 index 0000000..a21422c --- /dev/null +++ b/Ch11/Customcart/customcart/transparent.css @@ -0,0 +1,15 @@ +body { background:#68CE53; font-family:arial; font-size: 100%; +} +header {border:10px white solid;} +#container { + margin:auto; +} +h2 { margin-top: 20px; } +label { color: black; } +#submit {margin: 0px; background:#559a55; border: 5px outset #559a55; width: 140px;} +#includemenu {padding-top: 10px; padding-bottom: 10px; padding-right: 0px;} +#includefooter {background:#68CE53; padding-top: 5px; padding-bottom: 5px; margin: 0px;} +#includeheader {width:90%; height:auto; background:#95b522; margin-bottom: 0px; padding:0px;} +#contents {background-color:transparent ;margin-top: -17px; border:10px white solid; color: white; width: 90%; } +#buttons {background:#559a55; border: 5px outset #559a55;} + diff --git a/Ch11/Customcart/customcart/users_search_page.php b/Ch11/Customcart/customcart/users_search_page.php new file mode 100644 index 0000000..6282630 --- /dev/null +++ b/Ch11/Customcart/customcart/users_search_page.php @@ -0,0 +1,105 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    +

    Welcome to the Dove Gallery

    +
    All prices include frames, sales tax, delivery and insurance
    +

    Search for a painting

    +
    +
    + +
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    + + +
    + +
    + +
    + + +
    + + +
    +
    + +Copper Kettle by James Kessell + +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + + diff --git a/Ch11/Customcart/customcart/verify.js b/Ch11/Customcart/customcart/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch11/Customcart/customcart/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch11/Customcart/customcart52818.zip b/Ch11/Customcart/customcart52818.zip new file mode 100644 index 0000000..c0e2d56 Binary files /dev/null and b/Ch11/Customcart/customcart52818.zip differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/added.php b/Ch11/Customcart/customcartnew/customcartnew/added.php new file mode 100644 index 0000000..bbec459 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/added.php @@ -0,0 +1,100 @@ + + + + + Added to Cart + + + + + + + +
    + +
    + +
    + +
    +
    + +
    +
    +

    +Another one of those paintings has been added to your cart'; + } + else + { + // Add a different painting + $_SESSION['cart'][$id]= array ( 'quantity' => 1, 'price' => $row['price'] ) ; + echo '

    A painting has been added to your cart

    ' ; + } +} +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Added | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Added Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Added Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Added | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Added Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Added Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +// Close the database connection +mysqli_close($dbcon); +// Insert three lnks +echo '

    Continue Shopping | Checkout

    ' ; +?> +
    + +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/admin_add_artist.php b/Ch11/Customcart/customcartnew/customcartnew/admin_add_artist.php new file mode 100644 index 0000000..53f70bd --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/admin_add_artist.php @@ -0,0 +1,106 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add an Artist

    +
    If the artist uses only one name (e.g., Picasso) enter it as the last name
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/admin_add_painting.php b/Ch11/Customcart/customcartnew/customcartnew/admin_add_painting.php new file mode 100644 index 0000000..291066d --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/admin_add_painting.php @@ -0,0 +1,145 @@ + + + + + Add a Painting + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add a Painting

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Figures only, no £s, $s or commas +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    + +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/admin_page.php b/Ch11/Customcart/customcartnew/customcartnew/admin_page.php new file mode 100644 index 0000000..3adff80 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/admin_page.php @@ -0,0 +1,147 @@ + + + + + Add a Painting + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add a Painting

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Figures only, no £s, $s or commas +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/cart.php b/Ch11/Customcart/customcartnew/customcartnew/cart.php new file mode 100644 index 0000000..dd03ed0 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/cart.php @@ -0,0 +1,59 @@ + + + + + View Cart + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    + +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/checkout.php b/Ch11/Customcart/customcartnew/customcartnew/checkout.php new file mode 100644 index 0000000..d85c6c9 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/checkout.php @@ -0,0 +1,63 @@ + + + + + Template for an interactive web page + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    +
    +

    Thank you for your order. Your order number is +.

    +
    The shopping cart has been emptied ready for your next +transaction.
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/customdb.sql b/Ch11/Customcart/customcartnew/customcartnew/customdb.sql new file mode 100644 index 0000000..f464c3d --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/customdb.sql @@ -0,0 +1,273 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: May 28, 2018 at 08:36 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `customdb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `art` +-- + +CREATE TABLE `art` ( + `art_id` int(8) UNSIGNED NOT NULL, + `thumb` varchar(50) NOT NULL, + `type` varchar(50) NOT NULL, + `price` decimal(6,2) UNSIGNED NOT NULL, + `medium` varchar(50) NOT NULL, + `artist` varchar(50) NOT NULL, + `mini_descr` varchar(150) NOT NULL, + `ppcode` text NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `art` +-- + +INSERT INTO `art` (`art_id`, `thumb`, `type`, `price`, `medium`, `artist`, `mini_descr`, `ppcode`) VALUES +(1, '\"images/aw-brown-vessel-thumb.jpg\"', 'Still-life', '60.00', 'Oil-painting', 'Adrian-W-West', 'First exhibited in Coventry City Art Gallery 1968. Painted on durable tempered hardboard.', '

    \"\"

    '), +(2, '\"images/k-copper-kettle-thumb.jpg\"', 'Still-life', '750.00', 'Oil-painting', 'James-Kessell', 'James Kessell (RA and RABA) painted this on tempered hard board for an appreciative audience. It was exhibited at the Birmingham Art Gallery in 1967.', '

    \"\"

    '), +(3, '\"images/aw-white-jug-thumb.jpg\"', 'Still-life', '70.00', 'Oil-painting', 'Adrian-W-West', 'Painted on tempered hardboard in 1968 and exhibited first at Coventry City Art Gallery in the same year.', '

    \"\"

    '), +(4, '\"images/rsb-beer-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '), +(5, '\"images/rsb-blue-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Roger produces excellent etchings of Devon\'s native butterflies. ', '

    \"\"

    '), +(6, '\"images/rsb-fritillary-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'The silver washed fritillary is a less common Devon butterfly.', '

    \"\"

    '), +(7, '\"images/rsb-lyme-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(22, '\"images/rsb-lyme-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(23, '\"images/k-abstract-squares-thumb.jpg\"', 'Abstract', '800.00', 'Oil-painting', 'James-Kessell', 'Composition of squares and circles in tasteful pastel colors. Painted on high quality tempered board.', '

    \"\"

    '), +(21, '\"images/rsb-beer-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `artists` +-- + +CREATE TABLE `artists` ( + `artist_id` int(8) UNSIGNED NOT NULL, + `first_name` varchar(30) DEFAULT NULL, + `middle_name` varchar(30) DEFAULT NULL, + `last_name` varchar(30) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `artists` +-- + +INSERT INTO `artists` (`artist_id`, `first_name`, `middle_name`, `last_name`) VALUES +(1, 'Adrian', 'W', 'West'), +(2, 'Roger', 'St.', 'Barbe'), +(3, 'James', '', 'Kessell'), +(4, 'Charlie', 'S', 'Farnsbarns'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `orders` +-- + +CREATE TABLE `orders` ( + `order_id` int(8) UNSIGNED NOT NULL, + `buyer_id` int(8) UNSIGNED NOT NULL, + `total_price` decimal(7,2) NOT NULL, + `order_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_contents` +-- + +CREATE TABLE `order_contents` ( + `content_id` int(10) UNSIGNED NOT NULL, + `order_id` int(10) UNSIGNED NOT NULL, + `art_id` int(10) UNSIGNED NOT NULL, + `quantity` int(10) UNSIGNED NOT NULL DEFAULT '1', + `price` decimal(4,2) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `order_contents` +-- + +INSERT INTO `order_contents` (`content_id`, `order_id`, `art_id`, `quantity`, `price`) VALUES +(1, 2, 4, 1, '17.99'), +(2, 3, 4, 1, '17.99'), +(3, 4, 2, 1, '14.99'), +(4, 5, 3, 1, '16.99'), +(5, 6, 1, 1, '19.99'), +(6, 7, 1, 1, '60.00'), +(7, 8, 2, 1, '99.99'), +(8, 15, 1, 1, '60.00'), +(9, 16, 1, 1, '60.00'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_details` +-- + +CREATE TABLE `order_details` ( + `ord_details_id` int(8) UNSIGNED NOT NULL, + `order_id` int(8) UNSIGNED NOT NULL, + `art_id` int(8) UNSIGNED NOT NULL, + `dispatch_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `user_id` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `address1` varchar(50) NOT NULL, + `address2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `secret` varchar(30) NOT NULL, + `user_level` int(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`user_id`, `title`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `secret`, `user_level`) VALUES +(1, 'Mr', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UiiBhmXca.0/bwopveFq8uInuX.EVrecinUQYQG546WjAWwZLJNoe', '2017-12-06 08:43:41', '4 The Street', 'The Village', 'Townsville', 'USA', 'WA', '0123777888', '', 0), +(2, 'Mr', 'Jack', 'Smith', 'jsmith@outcook.com', '44fc2837cca3d8994cba9d02d94a15c1fe7b1d66', '2017-12-06 08:47:24', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(4, 'Ms', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$5KM8jy5MwHIgfVchsdfE8OvuF1cT2VYqU6mte2CWBw1HjmEv3r.ES', '2017-12-06 12:20:33', '6 The Street', '', 'Townsville', 'UK', 'EX9 9PG', '01234777888', '', 0), +(5, 'Mr', 'Patrick', 'O\'Hara', 'pohara@myisp.org.uk', '$2y$10$0nmGDVmHdWusgFJRmVZADeL43Y7HCPViBrHj/Z2betxiMdMx5Y2sC', '2017-12-06 12:27:32', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(6, 'Mr', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$KCQhEftEJouWPfuOOVoRVOECY/oJTluxHRr85fWlz6nsfN4OHtCie', '2017-12-06 17:02:16', '6 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PS', '', '', 0), +(7, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$IrQE3TTkWzNm93FP/VYf.O/yMWDJDpIn/.qjrmvN.I97fvakynuza', '2017-12-06 17:11:44', '7 The Street', 'The Village', 'Townsville', 'UK', 'EXP 6PG', '01234777888', '', 0), +(8, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$R2auBMKMe/Qw2fFr8D.S8eUEENUz8r.YUth5NHAyskNYupUzBen5O', '2017-12-06 17:18:30', '7 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(9, 'Mrs', 'Annie', 'Mossity', 'amossity@myisp.org.uk', '$2y$10$amqmyEfaOfiZ0MkIzdO90uZMPw4Mi/4RR70nNd0nxaZSOlxlr.8DC', '2017-12-06 17:24:42', '4 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '', 0), +(10, 'Mr', 'Percy', 'Veer', 'pveer@myisp.com', '$2y$10$Wvdx/YO4cCcOQvyMVVtapO3F/eiz2Ow3yU9VcczGMC.dcgwbgIXMS', '2017-12-06 17:28:53', '7 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '', 0), +(11, 'Mr', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$cTmJVcuUmTpCOIdQJ8MG3uwLmG7M7V3iE8zPXiNW2PQEdDQZMBftO', '2017-12-06 17:39:30', '5 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(12, 'Mr', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$YUYnU8UvOF/WUJ5h4VK4Qe.I48ZcAbedjPiDekKHlODduqGdJoI9i', '2017-12-06 18:02:04', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '', 0), +(13, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$k9sMvE001164jjzJLs.OpOmb9LtluUEbR4GQ4RT5/rvSPNIqbL6gC', '2017-12-07 17:39:34', '6 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '', 0), +(14, 'Mr', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$TOr.IZq/joHIKSk0Oo.jE.yWau48sUSgtC5TzKJ0sl0AoO2Bsk3lW', '2017-12-08 12:16:58', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '', 0), +(16, 'Miss', 'Lynn', 'Seed', 'lseed@myisp.com', '$2y$10$nEs3Zhh4V5ZznpcPzGs9gOWupjY2NgV87DPpLu2DjqsdyBNRjf4/C', '2017-12-16 20:03:16', '6 The Street', '', 'Townsville', 'UK', 'EX24 6PG', '01234777888', '', 0), +(17, 'Mr', 'Barry', 'Tone', 'btone@myisp.net', '$2y$10$w4zMq7ij7NmVDeBBKDSmbu963EwchZwAHPZmgZmTQAQ8Gha2jTD5W', '2017-12-16 20:16:40', '2 The Street', '', 'Townsville', 'USA', 'CA12345', '', '', 0), +(30, 'Mr', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$lePdxFz7ZKn/bJ41BS0h/ehWyIL2ZgK123iPQJahNCaRjgxVY3Rfq', '2017-12-29 11:28:43', '2 The Street', 'The Village', 'Townsville', 'Germany', 'BL1234', '', '', 0), +(31, 'Miss', 'Dee', 'Jected', 'djected@myisp.org.uk', '$2y$10$ujpV7w4blsTdQFWOsE1fiOFYtj9zN4w0WcK5V4WJ60Pc5HWodWlGC', '2017-12-29 11:48:04', '3 The Street', 'The Village', 'Townsville', 'UK', 'EX3 1TH', '', '', 0), +(32, 'Mr', 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$Yu.c/cw/TSFa9vcMBGAfAe5vzyOwp3SZarBVc/9vEksfp.F8BzSiW', '2017-12-29 11:58:51', '2 The Street', '', 'Townsville', 'UK', 'EX24 6PS', '01234777888', '', 0), +(40, NULL, 'Stuff', 'Stuff', 'stuff@stuff.com', '$2y$10$5D9RsKOqA/hr/Z.7ko/.M.ngQSqWDzOfnu7OhUnBLzxXwKVxHk6YW', '2018-05-25 16:52:54', '121 sd', NULL, 'fh', 'dj', '33333', '1233333333', 'dfd', 1), +(41, NULL, 'xx', 'xx', 'ccc@ccc.com', '$2y$10$dxTlEJ82C3g99CUmSuUWbOFyg8CT42jFhz.cgHqrkMhqxyIajbgKi', '2018-05-27 10:00:33', '44 as', NULL, 'kl', 'kl', '33333', NULL, 'fred', 0), +(42, NULL, 'Mx', 'asaa', 'mmm@mmm.com', '$2y$10$7iVu8Thd3ZEBTu0.aRtud.6qNtplrJ/jembAUcfEFwczEN42PkFii', '2018-05-27 10:02:28', '123 as', NULL, 'kw', 'fl', '33333', NULL, 'fred', 0); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `art` +-- +ALTER TABLE `art` + ADD PRIMARY KEY (`art_id`), + ADD KEY `art_name` (`thumb`,`price`); + +-- +-- Indexes for table `artists` +-- +ALTER TABLE `artists` + ADD PRIMARY KEY (`artist_id`); + +-- +-- Indexes for table `orders` +-- +ALTER TABLE `orders` + ADD PRIMARY KEY (`order_id`), + ADD KEY `buyer_id` (`buyer_id`,`order_date`); + +-- +-- Indexes for table `order_contents` +-- +ALTER TABLE `order_contents` + ADD PRIMARY KEY (`content_id`); + +-- +-- Indexes for table `order_details` +-- +ALTER TABLE `order_details` + ADD PRIMARY KEY (`ord_details_id`), + ADD KEY `order_id` (`order_id`,`art_id`,`dispatch_date`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`user_id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `art` +-- +ALTER TABLE `art` + MODIFY `art_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31; + +-- +-- AUTO_INCREMENT for table `artists` +-- +ALTER TABLE `artists` + MODIFY `artist_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=50; + +-- +-- AUTO_INCREMENT for table `orders` +-- +ALTER TABLE `orders` + MODIFY `order_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `order_contents` +-- +ALTER TABLE `order_contents` + MODIFY `content_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; + +-- +-- AUTO_INCREMENT for table `order_details` +-- +ALTER TABLE `order_details` + MODIFY `ord_details_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `user_id` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=43; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch11/Customcart/customcartnew/customcartnew/forgot.php b/Ch11/Customcart/customcartnew/customcartnew/forgot.php new file mode 100644 index 0000000..28cff5d --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/forgot.php @@ -0,0 +1,97 @@ + + + + + Forgot Password + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Forgot Your Password?

    +
    When you apply, you will receive your new password in an email. Read that +email as soon as possible. Don't delay! For +maximum security, immediately login with your new password. Then change the +password as quickly as possible.
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + + If you don't know your secret answer, contact our service department. +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/found_pics_cart.php b/Ch11/Customcart/customcartnew/customcartnew/found_pics_cart.php new file mode 100644 index 0000000..6068d58 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/found_pics_cart.php @@ -0,0 +1,60 @@ + + + + + Paintings Found + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +

    To buy a painting please click its Add to Cart link

    + +

    No paintings displayed? Either we have nothing that matches +your requirements at the moment OR you may have forgotten to select +BOTH the search fields. Please click the Find Pictures button and try again.

    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/L-looking-back-a-beer.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/L-looking-back-a-beer.jpg new file mode 100644 index 0000000..bf6152f Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/L-looking-back-a-beer.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/L-silver-studded-blue.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/L-silver-studded-blue.jpg new file mode 100644 index 0000000..c45da2f Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/L-silver-studded-blue.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/Thumbs.db b/Ch11/Customcart/customcartnew/customcartnew/images/Thumbs.db new file mode 100644 index 0000000..faaaabf Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/Thumbs.db differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel-200.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel-200.jpg new file mode 100644 index 0000000..df6dde2 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel-200.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel-thumb.jpg new file mode 100644 index 0000000..26dcaa5 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel.jpg new file mode 100644 index 0000000..8f62c17 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/aw-brown-vessel.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug-home.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug-home.jpg new file mode 100644 index 0000000..8f92b65 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug-home.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug-thumb.jpg new file mode 100644 index 0000000..426d3df Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug.jpg new file mode 100644 index 0000000..d0d8f25 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/aw-white-jug.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/cart.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/cart.jpg new file mode 100644 index 0000000..27213e0 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/cart.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/dove-1.png b/Ch11/Customcart/customcartnew/customcartnew/images/dove-1.png new file mode 100644 index 0000000..69a4410 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/dove-1.png differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/green-grad-800.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/green-grad-800.jpg new file mode 100644 index 0000000..696ad2b Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/green-grad-800.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/home.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/home.jpg new file mode 100644 index 0000000..002c2c4 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/home.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-abstract-squares-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-abstract-squares-thumb.jpg new file mode 100644 index 0000000..80362b7 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-abstract-squares-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-abstract-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-abstract-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-abstract-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-300.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-300.jpg new file mode 100644 index 0000000..7bbaf16 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-300.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-home.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-home.jpg new file mode 100644 index 0000000..957e09d Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-home.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-thumb.jpg new file mode 100644 index 0000000..27ca9f7 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-copper-kettle-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-2.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-2.jpg new file mode 100644 index 0000000..f22b330 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-2.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-3.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-3.jpg new file mode 100644 index 0000000..7e92b77 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-3.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-stil-life-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/k-still-life-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/k-still-life-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/k-still-life-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-looking-back-a-beer.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-looking-back-a-beer.jpg new file mode 100644 index 0000000..bf6152f Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-looking-back-a-beer.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-silver-studded-blue.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-silver-studded-blue.jpg new file mode 100644 index 0000000..c45da2f Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-silver-studded-blue.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-silver-washed=fritillary.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-silver-washed=fritillary.jpg new file mode 100644 index 0000000..9067c77 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/L-silver-washed=fritillary.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/Thumbs.db b/Ch11/Customcart/customcartnew/customcartnew/images/large files/Thumbs.db new file mode 100644 index 0000000..b80fb46 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/Thumbs.db differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-brown-vessel-200.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-brown-vessel-200.jpg new file mode 100644 index 0000000..df6dde2 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-brown-vessel-200.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-brown-vessel.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-brown-vessel.jpg new file mode 100644 index 0000000..8f62c17 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-brown-vessel.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug-200.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug-200.jpg new file mode 100644 index 0000000..87f6c8a Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug-200.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug-home.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug-home.jpg new file mode 100644 index 0000000..35425ca Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug-home.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug.jpg new file mode 100644 index 0000000..d0d8f25 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/aw-white-jug.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-copper-kettle-380.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-copper-kettle-380.jpg new file mode 100644 index 0000000..e1c21f0 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-copper-kettle-380.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-2.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-2.jpg new file mode 100644 index 0000000..f22b330 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-2.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-3.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-3.jpg new file mode 100644 index 0000000..7e92b77 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-3.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-300.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-300.jpg new file mode 100644 index 0000000..01bbc4f Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/large files/k-stil-life-300.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/prints.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/prints.jpg new file mode 100644 index 0000000..01a7209 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/prints.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/rsb-beer-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-beer-thumb.jpg new file mode 100644 index 0000000..196ca9c Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-beer-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/rsb-blue-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-blue-thumb.jpg new file mode 100644 index 0000000..fe2b0c9 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-blue-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/rsb-fritillary-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-fritillary-thumb.jpg new file mode 100644 index 0000000..1ea329f Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-fritillary-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/rsb-lyme-thumb.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-lyme-thumb.jpg new file mode 100644 index 0000000..ddb1800 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/rsb-lyme-thumb.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/title.jpg b/Ch11/Customcart/customcartnew/customcartnew/images/title.jpg new file mode 100644 index 0000000..5e38df9 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/title.jpg differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/images/unavailable.png b/Ch11/Customcart/customcartnew/customcartnew/images/unavailable.png new file mode 100644 index 0000000..41374c4 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew/images/unavailable.png differ diff --git a/Ch11/Customcart/customcartnew/customcartnew/includes/footer.php b/Ch11/Customcart/customcartnew/customcartnew/includes/footer.php new file mode 100644 index 0000000..6f56f56 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/includes/footer.php @@ -0,0 +1 @@ +

    Footer goes here

    \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/includes/header.php b/Ch11/Customcart/customcartnew/customcartnew/includes/header.php new file mode 100644 index 0000000..cc291fb --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/includes/header.php @@ -0,0 +1,117 @@ + + + + +
    +dove +
    +
    +
    The Dove Gallery
    +

    Affordable Original Paintings

    +
    + +
    + +
    \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/includes/menu.php b/Ch11/Customcart/customcartnew/customcartnew/includes/menu.php new file mode 100644 index 0000000..5f44ec0 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/includes/menu.php @@ -0,0 +1,27 @@ + + + +
    + +
    \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/index.php b/Ch11/Customcart/customcartnew/customcartnew/index.php new file mode 100644 index 0000000..dd8e55e --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/index.php @@ -0,0 +1,64 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    +
    +

    Welcome to the Dove Gallery

    +
    To search the gallery, please register and log in
    +

    +Brown Jug by Adrian West +L-Silver washed blue +White Jug +

    +
    + +
    +
    +
    +
    +Copper kettle +Looking Back at Beer +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/login-files/login.php b/Ch11/Customcart/customcartnew/customcartnew/login-files/login.php new file mode 100644 index 0000000..640deaf --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/login-files/login.php @@ -0,0 +1,47 @@ + + + +Login page + + + + + +
    +
    +
    + +
    +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +

    Login

    +
    +

    +

    +

    +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/login-files/login_functions.php b/Ch11/Customcart/customcartnew/customcartnew/login-files/login_functions.php new file mode 100644 index 0000000..7bc1283 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/login-files/login_functions.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/login.php b/Ch11/Customcart/customcartnew/customcartnew/login.php new file mode 100644 index 0000000..cd3f266 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/login.php @@ -0,0 +1,100 @@ + + + + + Login Page + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +
    +
    + +
    +

    Login

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/login_functions.php b/Ch11/Customcart/customcartnew/customcartnew/login_functions.php new file mode 100644 index 0000000..88ee47e --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/login_functions.php @@ -0,0 +1,76 @@ +getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Login | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Login Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Login Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } + // Retrieve the error messages + return array( false, $errors ) ; +} \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/login_toolss.php b/Ch11/Customcart/customcartnew/customcartnew/login_toolss.php new file mode 100644 index 0000000..b634d7f --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/login_toolss.php @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/mysqli_connect.php b/Ch11/Customcart/customcartnew/customcartnew/mysqli_connect.php new file mode 100644 index 0000000..26eb5ed --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/mysqli_connect.php @@ -0,0 +1,12 @@ +The painting was successfully registered
    '; + } else { // If it was not registered + // Error message: + echo '

    System Error

    +

    The painting could not be added due to a system error. We apologize for any inconvenience.

    '; + // Debugging message: + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Add Painting | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Add Painting Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Add Painting Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Add Painting | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Add Painting Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Add Painting Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display the errors. + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Print each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if (empty($errors)) +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/process_admin_page.php b/Ch11/Customcart/customcartnew/customcartnew/process_admin_page.php new file mode 100644 index 0000000..9e83197 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/process_admin_page.php @@ -0,0 +1,91 @@ +The artist was successfully added.'; + } else { // If the query failed to run + // Message: + echo '

    System Error

    +

    The artist could not be added due to a system error. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Admin Page | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Admin Page Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Admin Page Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Admin Page | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Admin Page Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Admin Page Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display any errors + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Display any errors + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if error checks +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/process_cart.php b/Ch11/Customcart/customcartnew/customcartnew/process_cart.php new file mode 100644 index 0000000..448bcf7 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/process_cart.php @@ -0,0 +1,85 @@ + $item_qty ) + { +// Ensure that the id and the quantity are integers + $id = (int) $art_id; + $qty = (int) $item_qty; +// If the quantity is set to zero clear the session or else store the changed quantity + if ( $qty == 0 ) { unset ($_SESSION['cart'][$id]); } + elseif ( $qty > 0 ) { $_SESSION['cart'][$id]['quantity'] = $qty; } + } + } +// Set an initial variable for the total cost +$total = 0; +// Display the cart contents +if (!empty($_SESSION['cart'])) +{ +?> +
    + +
    +
    + $value) { $q .= $id . ','; } + $q = substr( $q, 0, -1 ) . ') ORDER BY art_id ASC'; + $result = mysqli_query ($dbcon, $q); +// Create a form and a table + echo '
    '; + echo ''; + echo ''; + echo ''; + echo ''; + while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) + { +// Calculate the subtotals and the grand total + $subtotal = $_SESSION['cart'][$row['art_id']]['quantity'] * $_SESSION['cart'][$row['art_id']]['price']; + $total += $subtotal; +// Display the table + echo " + + "; + } +// Close the database connection + mysqli_close($dbcon); +// Display the total + echo ' +
    MediumTypeQuantityPrice
    {$row['type']}Painting(s)at {$row['price']} each ".number_format ($subtotal, 2)."
    Total = '.number_format($total,2).'
    '; + echo '
    '; + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Cart | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Cart Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Cart Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Cart | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Cart Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Cart Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +echo "
    "; +echo "
    "; +} +else +// Or display a message +{ echo '

    Your cart is currently empty.

    ' ; +} +// Create some links +echo '

    Continue Shopping | Checkout' ; +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/process_checkout.php b/Ch11/Customcart/customcartnew/customcartnew/process_checkout.php new file mode 100644 index 0000000..dd7eefa --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/process_checkout.php @@ -0,0 +1,55 @@ + 0 ) && (!empty($_SESSION['cart']) ) ) +{ + try { + // Connect to the database +require ( 'mysqli_connect.php' ) ; + // Insert the user's id, the total, and the order date into the orders table + + $query = "INSERT INTO orders ( user_id, total, order_date ) VALUES "; + $query .= "( ?, ?, NOW())"; + +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'is', $_SESSION['user_id'],$_GET['total']); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + $order_id = mysqli_insert_id($dbcon); + // Get the selected paintings from the art table + $q = "SELECT * FROM art WHERE 'art_id' IN ("; + foreach ($_SESSION['cart'] as $id => $value) { $q .= $id . ','; } + $q = substr( $q, 0, -1 ) . ') ORDER BY price ASC'; + $result = mysqli_query ($dbcon, $q); +// Insert the order contents into the order_contents table + while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) + { + $query = "INSERT INTO order_contents ( order_id, art_id, quantity, price ) + VALUES ( $order_id, ".$row['art_id'].",".$_SESSION['cart'][$row['art_id']]['quantity'].",".$_SESSION['cart'][$row['art_id']]['price'].")" ; + $result = mysqli_query($dbcon,$query); + } + // Close the database connection + mysqli_close($dbcon); + // Display a thank you message and state the order number + // Empty the cart ready for the next customer + $_SESSION['cart'] = NULL; +} + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +} +// Display a message +//else { echo '

    The shopping cart has been emptied ready for the next customer.

    ' ; } +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/process_forgot.php b/Ch11/Customcart/customcartnew/customcartnew/process_forgot.php new file mode 100644 index 0000000..ea204cc --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/process_forgot.php @@ -0,0 +1,75 @@ +If your e-mail and secret are correct, you will recieve an e-mail'; + } + } + if ($buyid) { // If buyid for the email address was retrieved, create a random password + $password = substr ( md5(uniqid(rand(), true)), 5, 10); +// Update the database table + $hassed_password = password_hash($password, PASSWORD_DEFAULT); + $query = "UPDATE users SET password=? WHERE user_id=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "si", $hassed_password, $buyid); + // execute query + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { +// Send an email to the buyer + $body = "Your password has been changed to '" . $password; + $body .= "'. Please login as soon as possible using the new password. "; + $body .= "Then change it immediately. otherwise, if a hacker has intercepted "; + $body .= "this email they will know your login details."; + mail ($_POST['email'], 'Your new password.', $body, 'From: admin@thedovegallery.co.uk'); +// Echo a message and exit the code + echo '
    Your password has been changed. '; + echo 'You will shortly receive the new temporary password by email.
    '; + mysqli_close($dbcon); + include ('includes/footer.php'); + exit(); // Stop the script. + } else { // If the query failed to run + echo '

    Due to a system error, your password could not be changed. We apologize for any inconvenience.

    '; + } + } + mysqli_close($dbcon); + } + catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Forgot Password | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Forgot Password Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Forgot Password Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Forgot Password | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Forgot Password Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Forgot Password Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/process_found_pics.php b/Ch11/Customcart/customcartnew/customcartnew/process_found_pics.php new file mode 100644 index 0000000..247316d --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/process_found_pics.php @@ -0,0 +1,73 @@ + 0) { + +//$result = mysqli_query( $dbcon, $q ) ; +//if ( mysqli_num_rows( $result ) > 0 ) +//{ +// Table header +?> + + + + + + + + + + + + + '; + } +?> +
    ThumbTypeMediumArtistDetailsPrice £
    ' . $row['type'] . '' . $row['medium'] . '' . $row['artist'] . '' . $row['mini_descr'] . '' . $row['price'] . + '
    Add to Cart
    +There are currently no items matching your search criteria.

    ' ; } +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Found Pics | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Found Pics Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Found Pics Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Found Pics | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Found Pics Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Found Pics Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/process_login.php b/Ch11/Customcart/customcartnew/customcartnew/process_login.php new file mode 100644 index 0000000..459f34e --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/process_login.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/process_register.php b/Ch11/Customcart/customcartnew/customcartnew/process_register.php new file mode 100644 index 0000000..264c58b --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/process_register.php @@ -0,0 +1,195 @@ + 60))) { + $errors[] = 'You forgot to enter your email address'; + $errors[] = ' or the e-mail format is incorrect.'; + } +// Check for a password and match against the confirmed password: +$password1trim = filter_var( $_POST['password1'], FILTER_SANITIZE_STRING); +if ((empty($password1trim)) || ($password1trim < 8) || ($password1trim > 12)){ // #7 +$errors[] ='Please enter a valid password'; +} +else { +if(!preg_match( '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,12}$/', +$password1trim)) { // #8 +$errors[] = 'Invalid password,8 to 12 chars, one upper, one lower, one number, one special.'; +} else +{ +$password2trim = filter_var( $_POST['password2'], FILTER_SANITIZE_STRING); +if($password1trim === $password2trim) { // #9 +$password = $password1trim; +}else{ +$errors[] = 'Your two password do not match.'; +$errors[] = 'Please try again'; +} +} +} +//Is the 1st address present? If it is, trim it and sanitize it +$address1 = filter_var( $_POST['address1'], FILTER_SANITIZE_STRING); +if ((!empty($address1)) && (preg_match('/[a-z\.\s\,\-]/i', $address1)) && + (strlen($address1) <= 30)) { + //Sanitize the trimmed 1st address + $address1trim = $address1; + }else{ + $errors[] = 'Missing address. Only alphabetic, period, comma, dash and space. Max 30.'; + } +//If the 2nd address is present? If it is, trim it and sanitize it #10 +$address2 = filter_var( $_POST['address2'], FILTER_SANITIZE_STRING); +if ((!empty($address2)) && (preg_match('/[a-z\.\s\,\-]/i', $address2)) && + (strlen($address2) <= 30)) { + //Sanitize the trimmed 2nd address + $address2trim = $address2; + }else{ + $address2trim = NULL; + } +//Is the city present? If it is, trim it and sanitize it +$city = filter_var( $_POST['city'], FILTER_SANITIZE_STRING); +if ((!empty($city)) && (preg_match('/[a-z\.\s]/i', $city)) && + (strlen($city) <= 30)) { + //Sanitize the trimmed city + $citytrim = $city; + }else{ + $errors[] = 'Missing city. Only alphabetic, period and space. Max 30.'; + } +//Is the state or country present? If it is, trim it and sanitize it +$state_country = filter_var( $_POST['state_country'], FILTER_SANITIZE_STRING); +if ((!empty($state_country)) && (preg_match('/[a-z\.\s]/i', $state_country)) && + (strlen($state_country) <= 30)) { + //Sanitize the trimmed state or country + $state_citytrim = $state_country; + }else{ + $errors[] = 'Missing state/country. Only alphabetic, period and space. Max 30.'; + } +//Is the zip code or post code present? If it is, trim it and sanitize it +$zcode_pcode = filter_var( $_POST['zcode_pcode'], FILTER_SANITIZE_STRING); +if ((!empty($zcode_pcode)) && (preg_match('/[a-z0-9\s]/i', $zcode_pcode)) && + (strlen($zcode_pcode) <= 30) && (strlen($zcode_pcode >= 5))) { + //Sanitize the trimmed zcode_pcode + $zcode_pcodetrim = $zcode_pcode; + }else{ + $errors[] = 'Missing zip code or post code. Alphabetic, numeric, space only max 30 characters'; + } +//Is the secret present? If it is, trim it and sanitize it +$secret = filter_var( $_POST['secret'], FILTER_SANITIZE_STRING); +if ((!empty($secret)) && (preg_match('/[a-z\.\s\,\-]/i', $secret)) && + (strlen($secret) <= 30)) { + //Sanitize the trimmed city + $secrettrim = $secret; + }else{ + $errors[] = 'Missing city. Only alphabetic, period, comma, dash and space. Max 30.'; + } +//Is the phone number present? If it is, trim it and sanitize it +$phone = filter_var( $_POST['phone'], FILTER_SANITIZE_STRING); +if ((!empty($phone)) && (strlen($phone) <= 30)) { + //Sanitize the trimmed phone number + $phonetrim = (filter_var($phone, FILTER_SANITIZE_NUMBER_INT)); + $phonetrim = preg_replace('/[^0-9]/', '', $phonetrim); + }else{ + $phonetrim = NULL; + } +if (empty($errors)) { // If everything's OK. +// If no problems encountered, register user in the database +//Determine whether the email address has already been registered +$query = "SELECT user_id FROM users WHERE email = ? "; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +mysqli_stmt_bind_param($q,'s', $e); +mysqli_stmt_execute($q); +$result = mysqli_stmt_get_result($q); + +if (mysqli_num_rows($result) == 0){//The email address has not been registered +//already therefore register the user in the users table + //-------------Valid Entries - Save to database ----- + //Start of the SUCCESSFUL SECTION. i.e all the required fields were filled out + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + // Register the user in the database... + $query = "INSERT INTO users (user_id, title, first_name, last_name, email, password,"; + $query .= "address1, address2, city, state_country, zcode_pcode, phone, secret, registration_date) "; + $query .= "VALUES "; + $query .= "(' ',?,?,?,?,?,?,?,?,?,?,?,?,NOW())"; +$q = mysqli_stmt_init($dbcon); +mysqli_stmt_prepare($q, $query); +// use prepared statement to insure that only text is inserted +// bind fields to SQL Statement +mysqli_stmt_bind_param($q, 'ssssssssssss', + $titletrim, $first_nametrim, $last_nametrim, $emailtrim, $hashed_password, $address1trim, $address2trim, + $citytrim, $state_countrytrim, $zcode_pcodetrim, $phonetrim, $secrettrim); +// execute query +mysqli_stmt_execute($q); +if (mysqli_stmt_affected_rows($q) == 1) { + header ("location: register_thanks.php"); + } else { + echo 'Invalid query:' . $dbcon->error; +// change to generic message in production + } + }else{//The email address is already registered +echo '

    The email address is already registered

    '; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +echo '

    Error!

    +

    The following error(s) occurred:
    '; +foreach ($errors as $msg) { // Print each error. +echo " - $msg
    \n"; + } +echo '

    Please try again.


    '; + }// End of if (empty($errors)) IF. +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Registration | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Register Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Register Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Registration | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Register Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Register Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/register.php b/Ch11/Customcart/customcartnew/customcartnew/register.php new file mode 100644 index 0000000..6c643f5 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/register.php @@ -0,0 +1,217 @@ + + + + + Template for an interactive web page + + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Account Registration

    +
    Items marked with an asterisk * are essential
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + Between 8 and 12 characters. +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/register_thanks.php b/Ch11/Customcart/customcartnew/customcartnew/register_thanks.php new file mode 100644 index 0000000..9576943 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/register_thanks.php @@ -0,0 +1,38 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    +

    Thank you for registering

    +
    You will now be able to login, search for, and view the paintings.
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew/transparent.css b/Ch11/Customcart/customcartnew/customcartnew/transparent.css new file mode 100644 index 0000000..a21422c --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/transparent.css @@ -0,0 +1,15 @@ +body { background:#68CE53; font-family:arial; font-size: 100%; +} +header {border:10px white solid;} +#container { + margin:auto; +} +h2 { margin-top: 20px; } +label { color: black; } +#submit {margin: 0px; background:#559a55; border: 5px outset #559a55; width: 140px;} +#includemenu {padding-top: 10px; padding-bottom: 10px; padding-right: 0px;} +#includefooter {background:#68CE53; padding-top: 5px; padding-bottom: 5px; margin: 0px;} +#includeheader {width:90%; height:auto; background:#95b522; margin-bottom: 0px; padding:0px;} +#contents {background-color:transparent ;margin-top: -17px; border:10px white solid; color: white; width: 90%; } +#buttons {background:#559a55; border: 5px outset #559a55;} + diff --git a/Ch11/Customcart/customcartnew/customcartnew/users_search_page.php b/Ch11/Customcart/customcartnew/customcartnew/users_search_page.php new file mode 100644 index 0000000..6282630 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/users_search_page.php @@ -0,0 +1,105 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    +

    Welcome to the Dove Gallery

    +
    All prices include frames, sales tax, delivery and insurance
    +

    Search for a painting

    +
    +
    + +
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    + + +
    + +
    + +
    + + +
    + + +
    +
    + +Copper Kettle by James Kessell + +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + + diff --git a/Ch11/Customcart/customcartnew/customcartnew/verify.js b/Ch11/Customcart/customcartnew/customcartnew/verify.js new file mode 100644 index 0000000..b5a9501 --- /dev/null +++ b/Ch11/Customcart/customcartnew/customcartnew/verify.js @@ -0,0 +1,12 @@ +function checked() { + if (document.getElementById('password1').value == + document.getElementById('password2').value) { + document.getElementById('message').style.color = 'green'; + document.getElementById('message').innerHTML = 'Passwords match'; + return true; + } else { + document.getElementById('message').style.color = 'red'; + document.getElementById('message').innerHTML = 'Passwords do not match'; + return false; + } +} \ No newline at end of file diff --git a/Ch11/Customcart/customcartnew/customcartnew53018v2.zip b/Ch11/Customcart/customcartnew/customcartnew53018v2.zip new file mode 100644 index 0000000..7c4abc3 Binary files /dev/null and b/Ch11/Customcart/customcartnew/customcartnew53018v2.zip differ diff --git a/Ch11/Customcart/customcartnewest.zip b/Ch11/Customcart/customcartnewest.zip new file mode 100644 index 0000000..1ee3545 Binary files /dev/null and b/Ch11/Customcart/customcartnewest.zip differ diff --git a/Ch11/Customcart/customdb.sql b/Ch11/Customcart/customdb.sql new file mode 100644 index 0000000..8473ce0 --- /dev/null +++ b/Ch11/Customcart/customdb.sql @@ -0,0 +1,295 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: May 12, 2018 at 10:47 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `customdb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `art` +-- + +CREATE TABLE `art` ( + `art_id` int(8) UNSIGNED NOT NULL, + `thumb` varchar(50) NOT NULL, + `type` varchar(50) NOT NULL, + `price` decimal(6,2) UNSIGNED NOT NULL, + `medium` varchar(50) NOT NULL, + `artist` varchar(50) NOT NULL, + `mini_descr` varchar(150) NOT NULL, + `ppcode` text NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `art` +-- + +INSERT INTO `art` (`art_id`, `thumb`, `type`, `price`, `medium`, `artist`, `mini_descr`, `ppcode`) VALUES +(1, '\"images/aw-brown-vessel-thumb.jpg\"', 'Still-life', '60.00', 'Oil-painting', 'Adrian-W-West', 'First exhibited in Coventry City Art Gallery 1968. Painted on durable tempered hardboard.', '

    \"\"

    '), +(2, '\"images/k-copper-kettle-thumb.jpg\"', 'Still-life', '750.00', 'Oil-painting', 'James-Kessell', 'James Kessell (RA and RABA) painted this on tempered hard board for an appreciative audience. It was exhibited at the Birmingham Art Gallery in 1967.', '

    \"\"

    '), +(3, '\"images/aw-white-jug-thumb.jpg\"', 'Still-life', '70.00', 'Oil-painting', 'Adrian-W-West', 'Painted on tempered hardboard in 1968 and exhibited first at Coventry City Art Gallery in the same year.', '

    \"\"

    '), +(4, '\"images/rsb-beer-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '), +(5, '\"images/rsb-blue-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Roger produces excellent etchings of Devon\'s native butterflies. ', '

    \"\"

    '), +(6, '\"images/rsb-fritillary-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'The silver washed fritillary is a less common Devon butterfly.', '

    \"\"

    '), +(7, '\"images/rsb-lyme-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(22, '\"images/rsb-lyme-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(23, '\"images/k-abstract-squares-thumb.jpg\"', 'Abstract', '800.00', 'Oil-painting', 'James-Kessell', 'Composition of squares and circles in tasteful pastel colors. Painted on high quality tempered board.', '

    \"\"

    '), +(21, '\"images/rsb-beer-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `artists` +-- + +CREATE TABLE `artists` ( + `artist_id` int(8) UNSIGNED NOT NULL, + `afname` varchar(30) DEFAULT NULL, + `amname` varchar(30) DEFAULT NULL, + `alname` varchar(30) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `artists` +-- + +INSERT INTO `artists` (`artist_id`, `afname`, `amname`, `alname`) VALUES +(1, 'Adrian', 'W', 'West'), +(2, 'Roger', 'St.', 'Barbe'), +(3, 'James', '', 'Kessell'), +(4, 'Charlie', 'S', 'Farnsbarns'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `orders` +-- + +CREATE TABLE `orders` ( + `order_id` int(8) UNSIGNED NOT NULL, + `buyer_id` int(8) UNSIGNED NOT NULL, + `total_price` decimal(7,2) NOT NULL, + `order_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_contents` +-- + +CREATE TABLE `order_contents` ( + `content_id` int(10) UNSIGNED NOT NULL, + `order_id` int(10) UNSIGNED NOT NULL, + `art_id` int(10) UNSIGNED NOT NULL, + `quantity` int(10) UNSIGNED NOT NULL DEFAULT '1', + `price` decimal(4,2) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `order_contents` +-- + +INSERT INTO `order_contents` (`content_id`, `order_id`, `art_id`, `quantity`, `price`) VALUES +(1, 2, 4, 1, '17.99'), +(2, 3, 4, 1, '17.99'), +(3, 4, 2, 1, '14.99'), +(4, 5, 3, 1, '16.99'), +(5, 6, 1, 1, '19.99'), +(6, 7, 1, 1, '60.00'), +(7, 8, 2, 1, '99.99'), +(8, 15, 1, 1, '60.00'), +(9, 16, 1, 1, '60.00'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_details` +-- + +CREATE TABLE `order_details` ( + `ord_details_id` int(8) UNSIGNED NOT NULL, + `order_id` int(8) UNSIGNED NOT NULL, + `art_id` int(8) UNSIGNED NOT NULL, + `dispatch_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prices` +-- + +CREATE TABLE `prices` ( + `oneyeargb` decimal(6,0) UNSIGNED NOT NULL, + `oneyearus` decimal(6,0) UNSIGNED NOT NULL, + `fiveyeargb` decimal(6,0) UNSIGNED NOT NULL, + `fiveyearus` decimal(6,0) UNSIGNED NOT NULL, + `militarygb` decimal(6,0) UNSIGNED NOT NULL, + `militaryus` decimal(6,0) UNSIGNED NOT NULL, + `u21gb` decimal(6,0) UNSIGNED NOT NULL, + `u21us` decimal(6,0) UNSIGNED NOT NULL, + `minpricegb` decimal(6,0) UNSIGNED NOT NULL, + `minpriceus` decimal(6,0) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `prices` +-- + +INSERT INTO `prices` (`oneyeargb`, `oneyearus`, `fiveyeargb`, `fiveyearus`, `militarygb`, `militaryus`, `u21gb`, `u21us`, `minpricegb`, `minpriceus`) VALUES +('30', '40', '125', '140', '5', '8', '2', '3', '15', '20'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `user_id` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext NOT NULL, + `fname` varchar(30) NOT NULL, + `lname` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `psword` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `addr1` varchar(50) NOT NULL, + `addr2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `user_level` int(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`user_id`, `title`, `fname`, `lname`, `email`, `psword`, `registration_date`, `addr1`, `addr2`, `city`, `state_country`, `zcode_pcode`, `phone`, `user_level`) VALUES +(1, 'Mr', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UiiBhmXca.0/bwopveFq8uInuX.EVrecinUQYQG546WjAWwZLJNoe', '2017-12-06 08:43:41', '4 The Street', 'The Village', 'Townsville', 'USA', 'WA', '0123777888', 0), +(2, 'Mr', 'Jack', 'Smith', 'jsmith@outcook.com', '44fc2837cca3d8994cba9d02d94a15c1fe7b1d66', '2017-12-06 08:47:24', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', 0), +(4, 'Ms', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$5KM8jy5MwHIgfVchsdfE8OvuF1cT2VYqU6mte2CWBw1HjmEv3r.ES', '2017-12-06 12:20:33', '6 The Street', '', 'Townsville', 'UK', 'EX9 9PG', '01234777888', 0), +(5, 'Mr', 'Patrick', 'O\'Hara', 'pohara@myisp.org.uk', '$2y$10$0nmGDVmHdWusgFJRmVZADeL43Y7HCPViBrHj/Z2betxiMdMx5Y2sC', '2017-12-06 12:27:32', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', 0), +(6, 'Mr', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$KCQhEftEJouWPfuOOVoRVOECY/oJTluxHRr85fWlz6nsfN4OHtCie', '2017-12-06 17:02:16', '6 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PS', '', 0), +(7, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$IrQE3TTkWzNm93FP/VYf.O/yMWDJDpIn/.qjrmvN.I97fvakynuza', '2017-12-06 17:11:44', '7 The Street', 'The Village', 'Townsville', 'UK', 'EXP 6PG', '01234777888', 0), +(8, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$R2auBMKMe/Qw2fFr8D.S8eUEENUz8r.YUth5NHAyskNYupUzBen5O', '2017-12-06 17:18:30', '7 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', 0), +(9, 'Mrs', 'Annie', 'Mossity', 'amossity@myisp.org.uk', '$2y$10$amqmyEfaOfiZ0MkIzdO90uZMPw4Mi/4RR70nNd0nxaZSOlxlr.8DC', '2017-12-06 17:24:42', '4 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 0), +(10, 'Mr', 'Percy', 'Veer', 'pveer@myisp.com', '$2y$10$Wvdx/YO4cCcOQvyMVVtapO3F/eiz2Ow3yU9VcczGMC.dcgwbgIXMS', '2017-12-06 17:28:53', '7 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PG', '01234777888', 0), +(11, 'Mr', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$cTmJVcuUmTpCOIdQJ8MG3uwLmG7M7V3iE8zPXiNW2PQEdDQZMBftO', '2017-12-06 17:39:30', '5 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '', 0), +(12, 'Mr', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$YUYnU8UvOF/WUJ5h4VK4Qe.I48ZcAbedjPiDekKHlODduqGdJoI9i', '2017-12-06 18:02:04', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '01234777888', 0), +(13, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$k9sMvE001164jjzJLs.OpOmb9LtluUEbR4GQ4RT5/rvSPNIqbL6gC', '2017-12-07 17:39:34', '6 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', 0), +(14, 'Mr', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$TOr.IZq/joHIKSk0Oo.jE.yWau48sUSgtC5TzKJ0sl0AoO2Bsk3lW', '2017-12-08 12:16:58', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PG', '01234777888', 0), +(16, 'Miss', 'Lynn', 'Seed', 'lseed@myisp.com', '$2y$10$nEs3Zhh4V5ZznpcPzGs9gOWupjY2NgV87DPpLu2DjqsdyBNRjf4/C', '2017-12-16 20:03:16', '6 The Street', '', 'Townsville', 'UK', 'EX24 6PG', '01234777888', 0), +(17, 'Mr', 'Barry', 'Tone', 'btone@myisp.net', '$2y$10$w4zMq7ij7NmVDeBBKDSmbu963EwchZwAHPZmgZmTQAQ8Gha2jTD5W', '2017-12-16 20:16:40', '2 The Street', '', 'Townsville', 'USA', 'CA12345', '', 0), +(30, 'Mr', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$lePdxFz7ZKn/bJ41BS0h/ehWyIL2ZgK123iPQJahNCaRjgxVY3Rfq', '2017-12-29 11:28:43', '2 The Street', 'The Village', 'Townsville', 'Germany', 'BL1234', '', 0), +(31, 'Miss', 'Dee', 'Jected', 'djected@myisp.org.uk', '$2y$10$ujpV7w4blsTdQFWOsE1fiOFYtj9zN4w0WcK5V4WJ60Pc5HWodWlGC', '2017-12-29 11:48:04', '3 The Street', 'The Village', 'Townsville', 'UK', 'EX3 1TH', '', 0), +(32, 'Mr', 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$Yu.c/cw/TSFa9vcMBGAfAe5vzyOwp3SZarBVc/9vEksfp.F8BzSiW', '2017-12-29 11:58:51', '2 The Street', '', 'Townsville', 'UK', 'EX24 6PS', '01234777888', 0); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `art` +-- +ALTER TABLE `art` + ADD PRIMARY KEY (`art_id`), + ADD KEY `art_name` (`thumb`,`price`); + +-- +-- Indexes for table `artists` +-- +ALTER TABLE `artists` + ADD PRIMARY KEY (`artist_id`); + +-- +-- Indexes for table `orders` +-- +ALTER TABLE `orders` + ADD PRIMARY KEY (`order_id`), + ADD KEY `buyer_id` (`buyer_id`,`order_date`); + +-- +-- Indexes for table `order_contents` +-- +ALTER TABLE `order_contents` + ADD PRIMARY KEY (`content_id`); + +-- +-- Indexes for table `order_details` +-- +ALTER TABLE `order_details` + ADD PRIMARY KEY (`ord_details_id`), + ADD KEY `order_id` (`order_id`,`art_id`,`dispatch_date`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`user_id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `art` +-- +ALTER TABLE `art` + MODIFY `art_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30; + +-- +-- AUTO_INCREMENT for table `artists` +-- +ALTER TABLE `artists` + MODIFY `artist_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33; + +-- +-- AUTO_INCREMENT for table `orders` +-- +ALTER TABLE `orders` + MODIFY `order_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `order_contents` +-- +ALTER TABLE `order_contents` + MODIFY `content_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; + +-- +-- AUTO_INCREMENT for table `order_details` +-- +ALTER TABLE `order_details` + MODIFY `ord_details_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `user_id` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch11/Customcart/forgot.php b/Ch11/Customcart/forgot.php new file mode 100644 index 0000000..b0c8394 --- /dev/null +++ b/Ch11/Customcart/forgot.php @@ -0,0 +1,113 @@ + + + +Forgotten password form + + + + + +
    +
    + +
    +
    +That email is not in the database

    '; + } + } + if ($buyid) { // If buyid for the email address was retrieved, create a random password + $password = substr ( md5(uniqid(rand(), true)), 5, 10); +// Update the database table + $hassed_password = password_hash($password, PASSWORD_BCRYPT); + $query = "UPDATE users SET password=? WHERE user_id=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "si", $hassed_password, $buyid); + // execute query + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { +// Send an email to the buyer + $body = "Your password has been changed to '" . $password . "'. Please login as soon as possible using the new password. "; + $body .= "Then change it immediately. otherwise, if a hacker has intercepted this email he will know your login details."; + mail ($_POST['email'], 'Your new password.', $body, 'From: admin@thedovegallery.co.uk'); +// Echo a message and exit the code + echo '

    Your password has been changed. You will shortly receive the new temporary password by email.

    '; + mysqli_close($dbcon); + include ('includes/footer.inc'); + exit(); // Stop the script. + } else { // If the query failed to run + echo '

    Due to a system error, your password could not be changed. We apologize for any inconvenience.

    '; + } + } + mysqli_close($dbcon); + } + catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +} +?> +
    + +
    +

    Forgotten Your Password?

    +

    When you apply, you will receive your new password in an email.
    Read that +email as soon as possible. Don't delay!
    For +maximum security, immediately login with your new password
    Then change the +password as quickly as possible.

    +
    +

    + +
    +

    +
    +
    + +

    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/found_paintings.css b/Ch11/Customcart/found_paintings.css new file mode 100644 index 0000000..253d081 --- /dev/null +++ b/Ch11/Customcart/found_paintings.css @@ -0,0 +1,10 @@ +p{ text-align:center; } +table, td, th { width:930px; border-collapse:collapse; border:1px black solid; background:white;} +td, th { padding-left:5px; padding-right:5px; text-align:center; } +td.narrow, th.narrow { width:45px;} +td.descr { text-align:left; } +td.medium, th.medium { width:100px;} +td.artist, th.artist { width:210px;} +td.thumb, th.thumb { width:125px; text-align:center;} +#content h3 { text-align:center; font-size:130%; font-weight:bold;} +img { display:block;} \ No newline at end of file diff --git a/Ch11/Customcart/found_pics_cart.php b/Ch11/Customcart/found_pics_cart.php new file mode 100644 index 0000000..4c0e04b --- /dev/null +++ b/Ch11/Customcart/found_pics_cart.php @@ -0,0 +1,80 @@ + + + + +The page for displaying the found paintings + + + + + +
    +
    + +
    +

    To buy a painting please click its Add to Cart link

    +

    + 0 ) +{ +// Table header +echo ' + + + + + + + +'; +// Fetch the matching records and populate the table display +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + echo ' + + + + + + + '; + } + echo '
    ThumbTypeMediumArtistDetailsPrice £
    ' . $row['type'] . '' . $row['medium'] . '' . $row['artist'] . '' . $row['mini_descr'] . '' . $row['price'] . + '
    Add to Cart
    '; // End of table +// Close the database connection. + mysqli_close( $dbcon ) ; +} +// Or notify the user that no matching paintings were found +else { echo '

    There are currently no items matching your search criteria.

    ' ; } +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> +

    No paintings displayed? Either we have nothing that matches your requirements at the moment OR
    you may have forgotten to select +BOTH the search fields. Please click the Home Page button and try again.

    +
    + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/header_found_pics_cart1.inc b/Ch11/Customcart/header_found_pics_cart1.inc new file mode 100644 index 0000000..97548f8 --- /dev/null +++ b/Ch11/Customcart/header_found_pics_cart1.inc @@ -0,0 +1,45 @@ +
    +dove + +
    +
    +

    Header Goes Here

    +
    + + + + + \ No newline at end of file diff --git a/Ch11/Customcart/images/L-looking-back-a-beer.jpg b/Ch11/Customcart/images/L-looking-back-a-beer.jpg new file mode 100644 index 0000000..bf6152f Binary files /dev/null and b/Ch11/Customcart/images/L-looking-back-a-beer.jpg differ diff --git a/Ch11/Customcart/images/L-silver-studded-blue.jpg b/Ch11/Customcart/images/L-silver-studded-blue.jpg new file mode 100644 index 0000000..c45da2f Binary files /dev/null and b/Ch11/Customcart/images/L-silver-studded-blue.jpg differ diff --git a/Ch11/Customcart/images/Thumbs.db b/Ch11/Customcart/images/Thumbs.db new file mode 100644 index 0000000..faaaabf Binary files /dev/null and b/Ch11/Customcart/images/Thumbs.db differ diff --git a/Ch11/Customcart/images/aw-brown-vessel-200.jpg b/Ch11/Customcart/images/aw-brown-vessel-200.jpg new file mode 100644 index 0000000..df6dde2 Binary files /dev/null and b/Ch11/Customcart/images/aw-brown-vessel-200.jpg differ diff --git a/Ch11/Customcart/images/aw-brown-vessel-thumb.jpg b/Ch11/Customcart/images/aw-brown-vessel-thumb.jpg new file mode 100644 index 0000000..26dcaa5 Binary files /dev/null and b/Ch11/Customcart/images/aw-brown-vessel-thumb.jpg differ diff --git a/Ch11/Customcart/images/aw-white-jug-home.jpg b/Ch11/Customcart/images/aw-white-jug-home.jpg new file mode 100644 index 0000000..8f92b65 Binary files /dev/null and b/Ch11/Customcart/images/aw-white-jug-home.jpg differ diff --git a/Ch11/Customcart/images/aw-white-jug-thumb.jpg b/Ch11/Customcart/images/aw-white-jug-thumb.jpg new file mode 100644 index 0000000..426d3df Binary files /dev/null and b/Ch11/Customcart/images/aw-white-jug-thumb.jpg differ diff --git a/Ch11/Customcart/images/dove-1.png b/Ch11/Customcart/images/dove-1.png new file mode 100644 index 0000000..69a4410 Binary files /dev/null and b/Ch11/Customcart/images/dove-1.png differ diff --git a/Ch11/Customcart/images/k-copper-kettle-300.jpg b/Ch11/Customcart/images/k-copper-kettle-300.jpg new file mode 100644 index 0000000..7bbaf16 Binary files /dev/null and b/Ch11/Customcart/images/k-copper-kettle-300.jpg differ diff --git a/Ch11/Customcart/images/k-copper-kettle-home.jpg b/Ch11/Customcart/images/k-copper-kettle-home.jpg new file mode 100644 index 0000000..957e09d Binary files /dev/null and b/Ch11/Customcart/images/k-copper-kettle-home.jpg differ diff --git a/Ch11/Customcart/images/k-copper-kettle-thumb.jpg b/Ch11/Customcart/images/k-copper-kettle-thumb.jpg new file mode 100644 index 0000000..27ca9f7 Binary files /dev/null and b/Ch11/Customcart/images/k-copper-kettle-thumb.jpg differ diff --git a/Ch11/Customcart/images/k-still-life-thumb.jpg b/Ch11/Customcart/images/k-still-life-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/Customcart/images/k-still-life-thumb.jpg differ diff --git a/Ch11/Customcart/images/rsb-beer-thumb.jpg b/Ch11/Customcart/images/rsb-beer-thumb.jpg new file mode 100644 index 0000000..196ca9c Binary files /dev/null and b/Ch11/Customcart/images/rsb-beer-thumb.jpg differ diff --git a/Ch11/Customcart/images/rsb-blue-thumb.jpg b/Ch11/Customcart/images/rsb-blue-thumb.jpg new file mode 100644 index 0000000..fe2b0c9 Binary files /dev/null and b/Ch11/Customcart/images/rsb-blue-thumb.jpg differ diff --git a/Ch11/Customcart/images/rsb-fritillary-thumb.jpg b/Ch11/Customcart/images/rsb-fritillary-thumb.jpg new file mode 100644 index 0000000..1ea329f Binary files /dev/null and b/Ch11/Customcart/images/rsb-fritillary-thumb.jpg differ diff --git a/Ch11/Customcart/images/rsb-lyme-thumb.jpg b/Ch11/Customcart/images/rsb-lyme-thumb.jpg new file mode 100644 index 0000000..ddb1800 Binary files /dev/null and b/Ch11/Customcart/images/rsb-lyme-thumb.jpg differ diff --git a/Ch11/Customcart/includes/footer.inc b/Ch11/Customcart/includes/footer.inc new file mode 100644 index 0000000..6048dd8 --- /dev/null +++ b/Ch11/Customcart/includes/footer.inc @@ -0,0 +1 @@ +

    Footer goes here

    \ No newline at end of file diff --git a/Ch11/Customcart/includes/footer.php b/Ch11/Customcart/includes/footer.php new file mode 100644 index 0000000..870c34f --- /dev/null +++ b/Ch11/Customcart/includes/footer.php @@ -0,0 +1 @@ +

    Footer goes here

    \ No newline at end of file diff --git a/Ch11/Customcart/includes/header_add_painting.inc b/Ch11/Customcart/includes/header_add_painting.inc new file mode 100644 index 0000000..8664bb7 --- /dev/null +++ b/Ch11/Customcart/includes/header_add_painting.inc @@ -0,0 +1,14 @@ + +

    The Dove Gallery

    +

    Affordable Original Paintings

    + diff --git a/Ch11/Customcart/includes/header_add_painting1.php b/Ch11/Customcart/includes/header_add_painting1.php new file mode 100644 index 0000000..3e90198 --- /dev/null +++ b/Ch11/Customcart/includes/header_add_painting1.php @@ -0,0 +1,16 @@ +
    + +
    +
    +
    The Dove Gallery
    +

    Affordable Original Paintings

    +
    + \ No newline at end of file diff --git a/Ch11/Customcart/includes/header_admin.inc b/Ch11/Customcart/includes/header_admin.inc new file mode 100644 index 0000000..243a8f4 --- /dev/null +++ b/Ch11/Customcart/includes/header_admin.inc @@ -0,0 +1,15 @@ + +

    The Dove Gallery

    +

    Affordable Original Paintings

    + diff --git a/Ch11/Customcart/includes/header_checkout.inc b/Ch11/Customcart/includes/header_checkout.inc new file mode 100644 index 0000000..4d7589d --- /dev/null +++ b/Ch11/Customcart/includes/header_checkout.inc @@ -0,0 +1,10 @@ +
    + +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    + diff --git a/Ch11/Customcart/includes/header_forgot.inc b/Ch11/Customcart/includes/header_forgot.inc new file mode 100644 index 0000000..7db9250 --- /dev/null +++ b/Ch11/Customcart/includes/header_forgot.inc @@ -0,0 +1,14 @@ +
    +
      + +
    +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    + diff --git a/Ch11/Customcart/includes/header_found_pics.inc b/Ch11/Customcart/includes/header_found_pics.inc new file mode 100644 index 0000000..ae30e07 --- /dev/null +++ b/Ch11/Customcart/includes/header_found_pics.inc @@ -0,0 +1,15 @@ +
    + +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    diff --git a/Ch11/Customcart/includes/header_found_pics_cart.inc b/Ch11/Customcart/includes/header_found_pics_cart.inc new file mode 100644 index 0000000..2d9aec5 --- /dev/null +++ b/Ch11/Customcart/includes/header_found_pics_cart.inc @@ -0,0 +1,26 @@ +
    + +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    + diff --git a/Ch11/Customcart/includes/header_found_pics_cart1.inc b/Ch11/Customcart/includes/header_found_pics_cart1.inc new file mode 100644 index 0000000..e2fae3b --- /dev/null +++ b/Ch11/Customcart/includes/header_found_pics_cart1.inc @@ -0,0 +1,46 @@ +
    +dove + +
    +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    +
    + + + + + \ No newline at end of file diff --git a/Ch11/Customcart/includes/header_found_pics_cart1.php b/Ch11/Customcart/includes/header_found_pics_cart1.php new file mode 100644 index 0000000..abef4a4 --- /dev/null +++ b/Ch11/Customcart/includes/header_found_pics_cart1.php @@ -0,0 +1,14 @@ +
    + +
    +
    +
    The Dove Gallery
    +

    Affordable Original Paintings

    +
    +
    + +
    \ No newline at end of file diff --git a/Ch11/Customcart/includes/header_home.inc b/Ch11/Customcart/includes/header_home.inc new file mode 100644 index 0000000..f521c10 --- /dev/null +++ b/Ch11/Customcart/includes/header_home.inc @@ -0,0 +1,14 @@ +
    + +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    + \ No newline at end of file diff --git a/Ch11/Customcart/includes/header_login.inc b/Ch11/Customcart/includes/header_login.inc new file mode 100644 index 0000000..28d8175 --- /dev/null +++ b/Ch11/Customcart/includes/header_login.inc @@ -0,0 +1,14 @@ +
    + +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    + \ No newline at end of file diff --git a/Ch11/Customcart/includes/header_reg.inc b/Ch11/Customcart/includes/header_reg.inc new file mode 100644 index 0000000..58d0d30 --- /dev/null +++ b/Ch11/Customcart/includes/header_reg.inc @@ -0,0 +1,10 @@ +
    + +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    + \ No newline at end of file diff --git a/Ch11/Customcart/includes/header_thanks.inc b/Ch11/Customcart/includes/header_thanks.inc new file mode 100644 index 0000000..6760554 --- /dev/null +++ b/Ch11/Customcart/includes/header_thanks.inc @@ -0,0 +1,15 @@ +
    + +
    +

    The Dove Gallery

    +

    Affordable Original Paintings

    + \ No newline at end of file diff --git a/Ch11/Customcart/includes/login_page.inc b/Ch11/Customcart/includes/login_page.inc new file mode 100644 index 0000000..ab01df8 --- /dev/null +++ b/Ch11/Customcart/includes/login_page.inc @@ -0,0 +1,8 @@ +

    Login

    +
    +

    +

    +

    +

    +

    +
    \ No newline at end of file diff --git a/Ch11/Customcart/includes/login_page.inc.php b/Ch11/Customcart/includes/login_page.inc.php new file mode 100644 index 0000000..ab01df8 --- /dev/null +++ b/Ch11/Customcart/includes/login_page.inc.php @@ -0,0 +1,8 @@ +

    Login

    +
    +

    +

    +

    +

    +

    +
    \ No newline at end of file diff --git a/Ch11/Customcart/includes/menu.inc b/Ch11/Customcart/includes/menu.inc new file mode 100644 index 0000000..683d52c --- /dev/null +++ b/Ch11/Customcart/includes/menu.inc @@ -0,0 +1,6 @@ + diff --git a/Ch11/Customcart/includes/menu1.php b/Ch11/Customcart/includes/menu1.php new file mode 100644 index 0000000..88646b1 --- /dev/null +++ b/Ch11/Customcart/includes/menu1.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/includes/style.css b/Ch11/Customcart/includes/style.css new file mode 100644 index 0000000..eec13e8 --- /dev/null +++ b/Ch11/Customcart/includes/style.css @@ -0,0 +1,6 @@ +header > h1 { border-bottom: 1px dashed black ; font-style: italic ; font-size: x-large; } +footer > p { border-top: 1px dashed black ; font-style: italic ; } +table { border-spacing:5px; width:530px;} +th { color:#FFF; background:#000; text-align:left; } +td { border-bottom:1px solid black; background:#F0F0F0; padding:3px; text-align:left; vertical-align:top;} +p#err_msg { color:#F00; font-weight:bold; } \ No newline at end of file diff --git a/Ch11/Customcart/index.php b/Ch11/Customcart/index.php new file mode 100644 index 0000000..365be98 --- /dev/null +++ b/Ch11/Customcart/index.php @@ -0,0 +1,38 @@ + + + +Home page + + + + + +
    +
    + +
    +
    +
    + +
    +
    +

    Welcome to the Dove Gallery

    + + +
    + +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/login-files/login.php b/Ch11/Customcart/login-files/login.php new file mode 100644 index 0000000..640deaf --- /dev/null +++ b/Ch11/Customcart/login-files/login.php @@ -0,0 +1,47 @@ + + + +Login page + + + + + +
    +
    +
    + +
    +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +

    Login

    +
    +

    +

    +

    +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/login-files/login_functions.php b/Ch11/Customcart/login-files/login_functions.php new file mode 100644 index 0000000..7bc1283 --- /dev/null +++ b/Ch11/Customcart/login-files/login_functions.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/login.php b/Ch11/Customcart/login.php new file mode 100644 index 0000000..5921a3a --- /dev/null +++ b/Ch11/Customcart/login.php @@ -0,0 +1,57 @@ + + + +Login page + + + + + +
    +
    + +
    +
    +
    + +
    +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +

    Login

    +
    +

    +

    + +

    + + Between 8 and 12 characters.

    +

    +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/login_functions.php b/Ch11/Customcart/login_functions.php new file mode 100644 index 0000000..945bcfb --- /dev/null +++ b/Ch11/Customcart/login_functions.php @@ -0,0 +1,66 @@ +getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} + } + // Retrieve the error messages + return array( false, $errors ) ; +} \ No newline at end of file diff --git a/Ch11/Customcart/login_toolss.php b/Ch11/Customcart/login_toolss.php new file mode 100644 index 0000000..b634d7f --- /dev/null +++ b/Ch11/Customcart/login_toolss.php @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/mysqli_connect.php b/Ch11/Customcart/mysqli_connect.php new file mode 100644 index 0000000..26eb5ed --- /dev/null +++ b/Ch11/Customcart/mysqli_connect.php @@ -0,0 +1,12 @@ +The painting was successfully registered
    '; + } else { // If it was not registered + // Error message: + echo '

    System Error

    +

    The painting could not be added due to a system error. We apologize for any inconvenience.

    '; + // Debugging message: + echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display the errors. + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Print each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if (empty($errors)) +?> \ No newline at end of file diff --git a/Ch11/Customcart/process_login.php b/Ch11/Customcart/process_login.php new file mode 100644 index 0000000..459f34e --- /dev/null +++ b/Ch11/Customcart/process_login.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/Ch11/Customcart/register-thanks.php b/Ch11/Customcart/register-thanks.php new file mode 100644 index 0000000..05a561d --- /dev/null +++ b/Ch11/Customcart/register-thanks.php @@ -0,0 +1,36 @@ + + + +Home page + + + + + +
    +
    + +
    +
    +
    + +
    + +
    +

    Thank you for registering

    +

    You will now be able to login, search for, and view the paintings.

    + +

    + +
    + +
    +
    + + + \ No newline at end of file diff --git a/Ch11/Customcart/register.css b/Ch11/Customcart/register.css new file mode 100644 index 0000000..83317e3 --- /dev/null +++ b/Ch11/Customcart/register.css @@ -0,0 +1,5 @@ +#midcol h2 { margin-left:-15px; } +#midcol h3 {margin-left:240px;;} +form { margin-left:150px; } +input { margin-bottom:5px;} +p.error { color:red; font-size:105%; font-weight:bold; text-align:center;} \ No newline at end of file diff --git a/Ch11/Customcart/register.php b/Ch11/Customcart/register.php new file mode 100644 index 0000000..8a5d7b7 --- /dev/null +++ b/Ch11/Customcart/register.php @@ -0,0 +1,243 @@ + + + +Registration page + + + + + + +
    +
    + +
    +
    +
    + +
    +error; +// change to generic message in production + } + }else{//The email address is already registered +echo '

    The email address is already registered

    '; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +echo '

    Error!

    +

    The following error(s) occurred:
    '; +foreach ($errors as $msg) { // Print each error. +echo " - $msg
    \n"; + } +echo '

    Please try again.


    '; + }// End of if (empty($errors)) IF. +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + //print "An Error occurred. Message: " . $e->getMessage(); +} +} +?> +
    +

    Account Registration

    +

    Items marked with an asterisk * are essential

    +
    + + + +
    + + +
    + + +
    + + +
    + 8 + to 12 characters + +
    + + +
    + + +
    + + +
    + + + +
    + + +
    + + +
    + + +

    +
    +
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/Customcart/search.css b/Ch11/Customcart/search.css new file mode 100644 index 0000000..c4d7ad5 --- /dev/null +++ b/Ch11/Customcart/search.css @@ -0,0 +1,7 @@ +p { font-size:110%; } +#midcol h2 { width:400px; } +#mid-left-col h3 {font-size:150%; text-align:left; } +select { width:130px; } +form { margin-left:170px; } +.search { margin:0 0 0 120px; font-weight:bold; font-size:130%; color:white; } +#submit { width:70px; margin-left:0; } \ No newline at end of file diff --git a/Ch11/Customcart/transparent.css b/Ch11/Customcart/transparent.css new file mode 100644 index 0000000..bd0cf8d --- /dev/null +++ b/Ch11/Customcart/transparent.css @@ -0,0 +1,64 @@ +/*equalise all the margins, paddings and borders built into various browsers +div body #header #content { margin:0; padding:0; border:0; +}*/ +body { background:#68CE53; font-family:arial; font-size: 100%; +} +/*add display attributes for the semantic tags*/ +/*header, footer, section, article, nav { display:block; +}*/ +header {border:10px white solid; +background:#95b522; +} +#logo { position:absolute; left:10px; top:5px;} +#container { + margin:auto; +} +#content { background-color:transparent; border:10px white solid; color: white; +} +#rightcol { width: 135px; float:right; height: 200px; margin-right:10px; +} +#midcol { margin-left:15px; margin-right:145px; margin-top:10px; vertical-align:top; +} +#midcol h2 { position:relative; left:325px; + +} +#mid-left-col { float:left; + width:47%; +} +#mid-right-col {float:right; + width:47%; +} +/* set side menu block position and width*/ + +nav li a:hover, #header-button li a:hover { background: red; color:white; border: 5px outset red; +} +/*mouse active*/ +nav li a:active { background:maroon; border: 5px inset maroon; +} +/*#ftr { + margin:auto; text-align:center; +}*/ +br.clear { clear:both; +} +#midcol img { margin-left:10px; +} +footer { clear:both; color:black; text-align:center; margin:auto; +} +table tr td { + background-color:#FFFFFF; text-align:center; border: 1px black solid; border-collapse:collapse; +} +.label { float:left; width:210px; text-align:right; clear:left; margin-right:5px; +} +#submit { margin-left:215px; text-align:center; +} + +#loginfields { display:block; margin-left:50px; +} +#loginfields input { float:left; margin-bottom:5px; +} +#loginfields label { margin-bottom:5px; font-weight:bold; +} +#loginfields span { float:left; +} +#loginfields submit { margin:5px auto 5px auto; +} diff --git a/Ch11/Customcart/users_search_page.php b/Ch11/Customcart/users_search_page.php new file mode 100644 index 0000000..3cf9035 --- /dev/null +++ b/Ch11/Customcart/users_search_page.php @@ -0,0 +1,69 @@ + + + + +The registered user's search page, custom cart version + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +

    Welcome to the Dove Gallery

    +

    All prices include frames, sales tax, delivery and insurance

    + +
    + Type
    +
    + Maximum Price
    +
    +

    +
    +
    +
    +

    Copper Kettle by James Kessell 

    +
    +
    +
    +
    + +
    +
    + + diff --git a/Ch11/paypalcart/admin_add_artist.php b/Ch11/paypalcart/admin_add_artist.php new file mode 100644 index 0000000..3d98109 --- /dev/null +++ b/Ch11/paypalcart/admin_add_artist.php @@ -0,0 +1,112 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add an Artist

    +
    If the artist uses only one name (e.g., Picasso) enter it as the last name
    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/admin_add_painting.php b/Ch11/paypalcart/admin_add_painting.php new file mode 100644 index 0000000..8b9e2b2 --- /dev/null +++ b/Ch11/paypalcart/admin_add_painting.php @@ -0,0 +1,156 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add a Painting

    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Figures only, no £s, $s or commas +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/admin_page.php b/Ch11/paypalcart/admin_page.php new file mode 100644 index 0000000..b225a68 --- /dev/null +++ b/Ch11/paypalcart/admin_page.php @@ -0,0 +1,164 @@ + + + + + Template for an interactive web page + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Add a Painting

    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Figures only, no £s, $s or commas +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/forgot.php b/Ch11/paypalcart/forgot.php new file mode 100644 index 0000000..d72e5ae --- /dev/null +++ b/Ch11/paypalcart/forgot.php @@ -0,0 +1,93 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Forgot Your Password?

    +
    When you apply, you will receive your new password in an email. Read that +email as soon as possible. Don't delay! For +maximum security, immediately login with your new password. Then change the +password as quickly as possible.
    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + If you don't know your secret answer, contact our service department. +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/found_paintings.php b/Ch11/paypalcart/found_paintings.php new file mode 100644 index 0000000..9a660f6 --- /dev/null +++ b/Ch11/paypalcart/found_paintings.php @@ -0,0 +1,56 @@ + + + + + Found Paintings + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +

    To buy a painting please click its Add to Cart link

    + +

    No paintings displayed? Either we have nothing that matches +your requirements at the moment OR you may have forgotten to select +BOTH the search fields. Please click the Home Page button and try again.

    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/images/L-looking-back-a-beer.jpg b/Ch11/paypalcart/images/L-looking-back-a-beer.jpg new file mode 100644 index 0000000..bf6152f Binary files /dev/null and b/Ch11/paypalcart/images/L-looking-back-a-beer.jpg differ diff --git a/Ch11/paypalcart/images/L-silver-studded-blue.jpg b/Ch11/paypalcart/images/L-silver-studded-blue.jpg new file mode 100644 index 0000000..c45da2f Binary files /dev/null and b/Ch11/paypalcart/images/L-silver-studded-blue.jpg differ diff --git a/Ch11/paypalcart/images/Thumbs.db b/Ch11/paypalcart/images/Thumbs.db new file mode 100644 index 0000000..faaaabf Binary files /dev/null and b/Ch11/paypalcart/images/Thumbs.db differ diff --git a/Ch11/paypalcart/images/aw-brown-vessel-200.jpg b/Ch11/paypalcart/images/aw-brown-vessel-200.jpg new file mode 100644 index 0000000..df6dde2 Binary files /dev/null and b/Ch11/paypalcart/images/aw-brown-vessel-200.jpg differ diff --git a/Ch11/paypalcart/images/aw-brown-vessel-thumb.jpg b/Ch11/paypalcart/images/aw-brown-vessel-thumb.jpg new file mode 100644 index 0000000..26dcaa5 Binary files /dev/null and b/Ch11/paypalcart/images/aw-brown-vessel-thumb.jpg differ diff --git a/Ch11/paypalcart/images/aw-brown-vessel.jpg b/Ch11/paypalcart/images/aw-brown-vessel.jpg new file mode 100644 index 0000000..8f62c17 Binary files /dev/null and b/Ch11/paypalcart/images/aw-brown-vessel.jpg differ diff --git a/Ch11/paypalcart/images/aw-white-jug-home.jpg b/Ch11/paypalcart/images/aw-white-jug-home.jpg new file mode 100644 index 0000000..8f92b65 Binary files /dev/null and b/Ch11/paypalcart/images/aw-white-jug-home.jpg differ diff --git a/Ch11/paypalcart/images/aw-white-jug-thumb.jpg b/Ch11/paypalcart/images/aw-white-jug-thumb.jpg new file mode 100644 index 0000000..426d3df Binary files /dev/null and b/Ch11/paypalcart/images/aw-white-jug-thumb.jpg differ diff --git a/Ch11/paypalcart/images/aw-white-jug.jpg b/Ch11/paypalcart/images/aw-white-jug.jpg new file mode 100644 index 0000000..d0d8f25 Binary files /dev/null and b/Ch11/paypalcart/images/aw-white-jug.jpg differ diff --git a/Ch11/paypalcart/images/cart.jpg b/Ch11/paypalcart/images/cart.jpg new file mode 100644 index 0000000..27213e0 Binary files /dev/null and b/Ch11/paypalcart/images/cart.jpg differ diff --git a/Ch11/paypalcart/images/dove-1.png b/Ch11/paypalcart/images/dove-1.png new file mode 100644 index 0000000..69a4410 Binary files /dev/null and b/Ch11/paypalcart/images/dove-1.png differ diff --git a/Ch11/paypalcart/images/green-grad-800.jpg b/Ch11/paypalcart/images/green-grad-800.jpg new file mode 100644 index 0000000..696ad2b Binary files /dev/null and b/Ch11/paypalcart/images/green-grad-800.jpg differ diff --git a/Ch11/paypalcart/images/home.jpg b/Ch11/paypalcart/images/home.jpg new file mode 100644 index 0000000..002c2c4 Binary files /dev/null and b/Ch11/paypalcart/images/home.jpg differ diff --git a/Ch11/paypalcart/images/k-abstract-squares-thumb.jpg b/Ch11/paypalcart/images/k-abstract-squares-thumb.jpg new file mode 100644 index 0000000..80362b7 Binary files /dev/null and b/Ch11/paypalcart/images/k-abstract-squares-thumb.jpg differ diff --git a/Ch11/paypalcart/images/k-abstract-thumb.jpg b/Ch11/paypalcart/images/k-abstract-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/paypalcart/images/k-abstract-thumb.jpg differ diff --git a/Ch11/paypalcart/images/k-copper-kettle-300.jpg b/Ch11/paypalcart/images/k-copper-kettle-300.jpg new file mode 100644 index 0000000..7bbaf16 Binary files /dev/null and b/Ch11/paypalcart/images/k-copper-kettle-300.jpg differ diff --git a/Ch11/paypalcart/images/k-copper-kettle-home.jpg b/Ch11/paypalcart/images/k-copper-kettle-home.jpg new file mode 100644 index 0000000..957e09d Binary files /dev/null and b/Ch11/paypalcart/images/k-copper-kettle-home.jpg differ diff --git a/Ch11/paypalcart/images/k-copper-kettle-thumb.jpg b/Ch11/paypalcart/images/k-copper-kettle-thumb.jpg new file mode 100644 index 0000000..27ca9f7 Binary files /dev/null and b/Ch11/paypalcart/images/k-copper-kettle-thumb.jpg differ diff --git a/Ch11/paypalcart/images/k-stil-life-2.jpg b/Ch11/paypalcart/images/k-stil-life-2.jpg new file mode 100644 index 0000000..f22b330 Binary files /dev/null and b/Ch11/paypalcart/images/k-stil-life-2.jpg differ diff --git a/Ch11/paypalcart/images/k-stil-life-3.jpg b/Ch11/paypalcart/images/k-stil-life-3.jpg new file mode 100644 index 0000000..7e92b77 Binary files /dev/null and b/Ch11/paypalcart/images/k-stil-life-3.jpg differ diff --git a/Ch11/paypalcart/images/k-stil-life-thumb.jpg b/Ch11/paypalcart/images/k-stil-life-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/paypalcart/images/k-stil-life-thumb.jpg differ diff --git a/Ch11/paypalcart/images/k-still-life-thumb.jpg b/Ch11/paypalcart/images/k-still-life-thumb.jpg new file mode 100644 index 0000000..35ac664 Binary files /dev/null and b/Ch11/paypalcart/images/k-still-life-thumb.jpg differ diff --git a/Ch11/paypalcart/images/large files/L-looking-back-a-beer.jpg b/Ch11/paypalcart/images/large files/L-looking-back-a-beer.jpg new file mode 100644 index 0000000..bf6152f Binary files /dev/null and b/Ch11/paypalcart/images/large files/L-looking-back-a-beer.jpg differ diff --git a/Ch11/paypalcart/images/large files/L-silver-studded-blue.jpg b/Ch11/paypalcart/images/large files/L-silver-studded-blue.jpg new file mode 100644 index 0000000..c45da2f Binary files /dev/null and b/Ch11/paypalcart/images/large files/L-silver-studded-blue.jpg differ diff --git a/Ch11/paypalcart/images/large files/L-silver-washed=fritillary.jpg b/Ch11/paypalcart/images/large files/L-silver-washed=fritillary.jpg new file mode 100644 index 0000000..9067c77 Binary files /dev/null and b/Ch11/paypalcart/images/large files/L-silver-washed=fritillary.jpg differ diff --git a/Ch11/paypalcart/images/large files/Thumbs.db b/Ch11/paypalcart/images/large files/Thumbs.db new file mode 100644 index 0000000..b80fb46 Binary files /dev/null and b/Ch11/paypalcart/images/large files/Thumbs.db differ diff --git a/Ch11/paypalcart/images/large files/aw-brown-vessel-200.jpg b/Ch11/paypalcart/images/large files/aw-brown-vessel-200.jpg new file mode 100644 index 0000000..df6dde2 Binary files /dev/null and b/Ch11/paypalcart/images/large files/aw-brown-vessel-200.jpg differ diff --git a/Ch11/paypalcart/images/large files/aw-brown-vessel.jpg b/Ch11/paypalcart/images/large files/aw-brown-vessel.jpg new file mode 100644 index 0000000..8f62c17 Binary files /dev/null and b/Ch11/paypalcart/images/large files/aw-brown-vessel.jpg differ diff --git a/Ch11/paypalcart/images/large files/aw-white-jug-200.jpg b/Ch11/paypalcart/images/large files/aw-white-jug-200.jpg new file mode 100644 index 0000000..87f6c8a Binary files /dev/null and b/Ch11/paypalcart/images/large files/aw-white-jug-200.jpg differ diff --git a/Ch11/paypalcart/images/large files/aw-white-jug-home.jpg b/Ch11/paypalcart/images/large files/aw-white-jug-home.jpg new file mode 100644 index 0000000..35425ca Binary files /dev/null and b/Ch11/paypalcart/images/large files/aw-white-jug-home.jpg differ diff --git a/Ch11/paypalcart/images/large files/aw-white-jug.jpg b/Ch11/paypalcart/images/large files/aw-white-jug.jpg new file mode 100644 index 0000000..d0d8f25 Binary files /dev/null and b/Ch11/paypalcart/images/large files/aw-white-jug.jpg differ diff --git a/Ch11/paypalcart/images/large files/k-copper-kettle-380.jpg b/Ch11/paypalcart/images/large files/k-copper-kettle-380.jpg new file mode 100644 index 0000000..e1c21f0 Binary files /dev/null and b/Ch11/paypalcart/images/large files/k-copper-kettle-380.jpg differ diff --git a/Ch11/paypalcart/images/large files/k-stil-life-2.jpg b/Ch11/paypalcart/images/large files/k-stil-life-2.jpg new file mode 100644 index 0000000..f22b330 Binary files /dev/null and b/Ch11/paypalcart/images/large files/k-stil-life-2.jpg differ diff --git a/Ch11/paypalcart/images/large files/k-stil-life-3.jpg b/Ch11/paypalcart/images/large files/k-stil-life-3.jpg new file mode 100644 index 0000000..7e92b77 Binary files /dev/null and b/Ch11/paypalcart/images/large files/k-stil-life-3.jpg differ diff --git a/Ch11/paypalcart/images/large files/k-stil-life-300.jpg b/Ch11/paypalcart/images/large files/k-stil-life-300.jpg new file mode 100644 index 0000000..01bbc4f Binary files /dev/null and b/Ch11/paypalcart/images/large files/k-stil-life-300.jpg differ diff --git a/Ch11/paypalcart/images/prints.jpg b/Ch11/paypalcart/images/prints.jpg new file mode 100644 index 0000000..01a7209 Binary files /dev/null and b/Ch11/paypalcart/images/prints.jpg differ diff --git a/Ch11/paypalcart/images/rsb-beer-thumb.jpg b/Ch11/paypalcart/images/rsb-beer-thumb.jpg new file mode 100644 index 0000000..196ca9c Binary files /dev/null and b/Ch11/paypalcart/images/rsb-beer-thumb.jpg differ diff --git a/Ch11/paypalcart/images/rsb-blue-thumb.jpg b/Ch11/paypalcart/images/rsb-blue-thumb.jpg new file mode 100644 index 0000000..fe2b0c9 Binary files /dev/null and b/Ch11/paypalcart/images/rsb-blue-thumb.jpg differ diff --git a/Ch11/paypalcart/images/rsb-fritillary-thumb.jpg b/Ch11/paypalcart/images/rsb-fritillary-thumb.jpg new file mode 100644 index 0000000..1ea329f Binary files /dev/null and b/Ch11/paypalcart/images/rsb-fritillary-thumb.jpg differ diff --git a/Ch11/paypalcart/images/rsb-lyme-thumb.jpg b/Ch11/paypalcart/images/rsb-lyme-thumb.jpg new file mode 100644 index 0000000..ddb1800 Binary files /dev/null and b/Ch11/paypalcart/images/rsb-lyme-thumb.jpg differ diff --git a/Ch11/paypalcart/images/title.jpg b/Ch11/paypalcart/images/title.jpg new file mode 100644 index 0000000..5e38df9 Binary files /dev/null and b/Ch11/paypalcart/images/title.jpg differ diff --git a/Ch11/paypalcart/images/unavailable.png b/Ch11/paypalcart/images/unavailable.png new file mode 100644 index 0000000..41374c4 Binary files /dev/null and b/Ch11/paypalcart/images/unavailable.png differ diff --git a/Ch11/paypalcart/includes/footer.php b/Ch11/paypalcart/includes/footer.php new file mode 100644 index 0000000..6f56f56 --- /dev/null +++ b/Ch11/paypalcart/includes/footer.php @@ -0,0 +1 @@ +

    Footer goes here

    \ No newline at end of file diff --git a/Ch11/paypalcart/includes/header.php b/Ch11/paypalcart/includes/header.php new file mode 100644 index 0000000..01b383d --- /dev/null +++ b/Ch11/paypalcart/includes/header.php @@ -0,0 +1,114 @@ + + + + +
    +dove +
    +
    +
    The Dove Gallery
    +

    Affordable Original Paintings

    +
    + +
    + +
    \ No newline at end of file diff --git a/Ch11/paypalcart/includes/menu.php b/Ch11/paypalcart/includes/menu.php new file mode 100644 index 0000000..5f44ec0 --- /dev/null +++ b/Ch11/paypalcart/includes/menu.php @@ -0,0 +1,27 @@ + + + +
    + +
    \ No newline at end of file diff --git a/Ch11/paypalcart/index.php b/Ch11/paypalcart/index.php new file mode 100644 index 0000000..a421afa --- /dev/null +++ b/Ch11/paypalcart/index.php @@ -0,0 +1,96 @@ + + + + + PayPal Cart Index Page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    +

    Welcome to the Dove Gallery

    +
    + All prices include frames, sales tax, delivery and insurance
    +

    Search for a painting

    +
    +
    +
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    + + +
    + +
    +
    +
    +
    +
    +Copper Kettle by James Kessell +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + + diff --git a/Ch11/paypalcart/login-files/login.php b/Ch11/paypalcart/login-files/login.php new file mode 100644 index 0000000..640deaf --- /dev/null +++ b/Ch11/paypalcart/login-files/login.php @@ -0,0 +1,47 @@ + + + +Login page + + + + + +
    +
    +
    + +
    +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +

    Login

    +
    +

    +

    +

    +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/login-files/login_functions.php b/Ch11/paypalcart/login-files/login_functions.php new file mode 100644 index 0000000..7bc1283 --- /dev/null +++ b/Ch11/paypalcart/login-files/login_functions.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/Ch11/paypalcart/login.php b/Ch11/paypalcart/login.php new file mode 100644 index 0000000..1a24a26 --- /dev/null +++ b/Ch11/paypalcart/login.php @@ -0,0 +1,107 @@ + + + + + Template for an interactive web page + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + +A problem occurred:
    ' ; + foreach ( $errors as $msg ) { echo " - $msg
    " ; } + echo 'Please try again or Register

    ' ; +} +?> + +
    +
    + +
    +

    Login

    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/login_functions.php b/Ch11/paypalcart/login_functions.php new file mode 100644 index 0000000..88ee47e --- /dev/null +++ b/Ch11/paypalcart/login_functions.php @@ -0,0 +1,76 @@ +getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Login | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Login Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Login Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } + // Retrieve the error messages + return array( false, $errors ) ; +} \ No newline at end of file diff --git a/Ch11/paypalcart/logout.php b/Ch11/paypalcart/logout.php new file mode 100644 index 0000000..07c13b0 --- /dev/null +++ b/Ch11/paypalcart/logout.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/Ch11/paypalcart/logs/error_log.log b/Ch11/paypalcart/logs/error_log.log new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/Ch11/paypalcart/logs/error_log.log @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Ch11/paypalcart/logs/exception_log.log b/Ch11/paypalcart/logs/exception_log.log new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/Ch11/paypalcart/logs/exception_log.log @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Ch11/paypalcart/mysqli_connect.php b/Ch11/paypalcart/mysqli_connect.php new file mode 100644 index 0000000..83c304b --- /dev/null +++ b/Ch11/paypalcart/mysqli_connect.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/Ch11/paypalcart/paypaldb.sql b/Ch11/paypalcart/paypaldb.sql new file mode 100644 index 0000000..373474e --- /dev/null +++ b/Ch11/paypalcart/paypaldb.sql @@ -0,0 +1,270 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.4 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: May 28, 2018 at 08:37 PM +-- Server version: 10.1.28-MariaDB +-- PHP Version: 7.1.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `paypaldb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `art` +-- + +CREATE TABLE `art` ( + `art_id` int(8) UNSIGNED NOT NULL, + `thumb` varchar(50) NOT NULL, + `type` varchar(50) NOT NULL, + `price` decimal(6,2) UNSIGNED NOT NULL, + `medium` varchar(50) NOT NULL, + `artist` varchar(50) NOT NULL, + `mini_descr` varchar(150) NOT NULL, + `ppcode` text NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `art` +-- + +INSERT INTO `art` (`art_id`, `thumb`, `type`, `price`, `medium`, `artist`, `mini_descr`, `ppcode`) VALUES +(1, '\"images/aw-brown-vessel-thumb.jpg\"', 'Still-life', '60.00', 'Oil-painting', 'Adrian-W-West', 'First exhibited in Coventry City Art Gallery 1968. Painted on durable tempered hardboard.', '

    \"\"

    '), +(2, '\"images/k-copper-kettle-thumb.jpg\"', 'Still-life', '750.00', 'Oil-painting', 'James-Kessell', 'James Kessell (RA and RABA) painted this on tempered hard board for an appreciative audience. It was exhibited at the Birmingham Art Gallery in 1967.', '

    \"\"

    '), +(3, '\"images/aw-white-jug-thumb.jpg\"', 'Still-life', '70.00', 'Oil-painting', 'Adrian-W-West', 'Painted on tempered hardboard in 1968 and exhibited first at Coventry City Art Gallery in the same year.', '

    \"\"

    '), +(4, '\"images/rsb-beer-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '), +(5, '\"images/rsb-blue-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Roger produces excellent etchings of Devon\'s native butterflies. ', '

    \"\"

    '), +(6, '\"images/rsb-fritillary-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'The silver washed fritillary is a less common Devon butterfly.', '

    \"\"

    '), +(7, '\"images/rsb-lyme-thumb.jpg\"', 'Nature', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(22, '\"images/rsb-lyme-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Lyme Regis is a popular Devon seaside resort with a spectacular sea wall called the Cobb.', '

    \"\"

    '), +(23, '\"images/k-abstract-squares-thumb.jpg\"', 'Abstract', '800.00', 'Oil-painting', 'James-Kessell', 'Composition of squares and circles in tasteful pastel colors. Painted on high quality tempered board.', '

    \"\"

    '), +(21, '\"images/rsb-beer-thumb.jpg\"', 'Landscape', '40.00', 'Colored-etching', 'Roger-St-Barbe', 'Looking back at Beer beach, South East Devon. ', '

    \"\"

    '); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `artists` +-- + +CREATE TABLE `artists` ( + `artist_id` int(8) UNSIGNED NOT NULL, + `first_name` varchar(30) DEFAULT NULL, + `middle_name` varchar(30) DEFAULT NULL, + `last_name` varchar(30) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `artists` +-- + +INSERT INTO `artists` (`artist_id`, `first_name`, `middle_name`, `last_name`) VALUES +(1, 'Adrian', 'W', 'West'), +(2, 'Roger', 'St.', 'Barbe'), +(3, 'James', '', 'Kessell'), +(4, 'Charlie', 'S', 'Farnsbarns'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `orders` +-- + +CREATE TABLE `orders` ( + `order_id` int(8) UNSIGNED NOT NULL, + `buyer_id` int(8) UNSIGNED NOT NULL, + `total_price` decimal(7,2) NOT NULL, + `order_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_contents` +-- + +CREATE TABLE `order_contents` ( + `content_id` int(10) UNSIGNED NOT NULL, + `order_id` int(10) UNSIGNED NOT NULL, + `art_id` int(10) UNSIGNED NOT NULL, + `quantity` int(10) UNSIGNED NOT NULL DEFAULT '1', + `price` decimal(4,2) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `order_contents` +-- + +INSERT INTO `order_contents` (`content_id`, `order_id`, `art_id`, `quantity`, `price`) VALUES +(1, 2, 4, 1, '17.99'), +(2, 3, 4, 1, '17.99'), +(3, 4, 2, 1, '14.99'), +(4, 5, 3, 1, '16.99'), +(5, 6, 1, 1, '19.99'), +(6, 7, 1, 1, '60.00'), +(7, 8, 2, 1, '99.99'), +(8, 15, 1, 1, '60.00'), +(9, 16, 1, 1, '60.00'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `order_details` +-- + +CREATE TABLE `order_details` ( + `ord_details_id` int(8) UNSIGNED NOT NULL, + `order_id` int(8) UNSIGNED NOT NULL, + `art_id` int(8) UNSIGNED NOT NULL, + `dispatch_date` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `user_id` mediumint(6) UNSIGNED NOT NULL, + `title` tinytext, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(40) NOT NULL, + `email` varchar(50) NOT NULL, + `password` char(60) NOT NULL, + `registration_date` datetime NOT NULL, + `address1` varchar(50) NOT NULL, + `address2` varchar(50) DEFAULT NULL, + `city` varchar(50) NOT NULL, + `state_country` char(25) NOT NULL, + `zcode_pcode` char(10) NOT NULL, + `phone` char(15) DEFAULT NULL, + `secret` varchar(30) NOT NULL, + `user_level` int(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`user_id`, `title`, `first_name`, `last_name`, `email`, `password`, `registration_date`, `address1`, `address2`, `city`, `state_country`, `zcode_pcode`, `phone`, `secret`, `user_level`) VALUES +(1, 'Mr', 'Mike', 'Rosoft', 'miker@myisp.com', '$2y$10$UiiBhmXca.0/bwopveFq8uInuX.EVrecinUQYQG546WjAWwZLJNoe', '2017-12-06 08:43:41', '4 The Street', 'The Village', 'Townsville', 'USA', 'WA', '0123777888', '0', 0), +(2, 'Mr', 'Jack', 'Smith', 'jsmith@outcook.com', '44fc2837cca3d8994cba9d02d94a15c1fe7b1d66', '2017-12-06 08:47:24', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '0', 0), +(4, 'Ms', 'Olive', 'Branch', 'obranch@myisp.co.uk', '$2y$10$5KM8jy5MwHIgfVchsdfE8OvuF1cT2VYqU6mte2CWBw1HjmEv3r.ES', '2017-12-06 12:20:33', '6 The Street', '', 'Townsville', 'UK', 'EX9 9PG', '01234777888', '0', 0), +(5, 'Mr', 'Patrick', 'O\'Hara', 'pohara@myisp.org.uk', '$2y$10$0nmGDVmHdWusgFJRmVZADeL43Y7HCPViBrHj/Z2betxiMdMx5Y2sC', '2017-12-06 12:27:32', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '0', 0), +(6, 'Mr', 'Frank', 'Incense', 'fincense@myisp.net', '$2y$10$KCQhEftEJouWPfuOOVoRVOECY/oJTluxHRr85fWlz6nsfN4OHtCie', '2017-12-06 17:02:16', '6 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PS', '', '0', 0), +(7, 'Miss', 'Annie', 'Versary', 'aversary@myisp.com', '$2y$10$IrQE3TTkWzNm93FP/VYf.O/yMWDJDpIn/.qjrmvN.I97fvakynuza', '2017-12-06 17:11:44', '7 The Street', 'The Village', 'Townsville', 'UK', 'EXP 6PG', '01234777888', '0', 0), +(8, 'Mrs', 'Rose', 'Bush', 'rbush@myisp.co.uk', '$2y$10$R2auBMKMe/Qw2fFr8D.S8eUEENUz8r.YUth5NHAyskNYupUzBen5O', '2017-12-06 17:18:30', '7 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '0', 0), +(9, 'Mrs', 'Annie', 'Mossity', 'amossity@myisp.org.uk', '$2y$10$amqmyEfaOfiZ0MkIzdO90uZMPw4Mi/4RR70nNd0nxaZSOlxlr.8DC', '2017-12-06 17:24:42', '4 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '0', 0), +(10, 'Mr', 'Percy', 'Veer', 'pveer@myisp.com', '$2y$10$Wvdx/YO4cCcOQvyMVVtapO3F/eiz2Ow3yU9VcczGMC.dcgwbgIXMS', '2017-12-06 17:28:53', '7 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '0', 0), +(11, 'Mr', 'Darrel', 'Doo', 'ddoo@myisp.co.uk', '$2y$10$cTmJVcuUmTpCOIdQJ8MG3uwLmG7M7V3iE8zPXiNW2PQEdDQZMBftO', '2017-12-06 17:39:30', '5 The Street', 'The Village', 'Townsville', 'UK', 'EX7 9PP', '', '0', 0), +(12, 'Mr', 'Stan', 'Dard', 'sdard@myisp.net', '$2y$10$YUYnU8UvOF/WUJ5h4VK4Qe.I48ZcAbedjPiDekKHlODduqGdJoI9i', '2017-12-06 18:02:04', '3 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '01234777888', '0', 0), +(13, 'Mrs', 'Nora', 'Bone', 'nbone@myisp.com', '$2y$10$k9sMvE001164jjzJLs.OpOmb9LtluUEbR4GQ4RT5/rvSPNIqbL6gC', '2017-12-07 17:39:34', '6 The Street', '', 'Townsville', 'UK', 'EX7 9PP', '', '0', 0), +(14, 'Mr', 'Barry', 'Cade', 'bcade@myisp.co.uk', '$2y$10$TOr.IZq/joHIKSk0Oo.jE.yWau48sUSgtC5TzKJ0sl0AoO2Bsk3lW', '2017-12-08 12:16:58', '5 The Street', '', 'Townsville', 'UK', 'EX7 9PG', '01234777888', '0', 0), +(16, 'Miss', 'Lynn', 'Seed', 'lseed@myisp.com', '$2y$10$nEs3Zhh4V5ZznpcPzGs9gOWupjY2NgV87DPpLu2DjqsdyBNRjf4/C', '2017-12-16 20:03:16', '6 The Street', '', 'Townsville', 'UK', 'EX24 6PG', '01234777888', '0', 0), +(17, 'Mr', 'Barry', 'Tone', 'btone@myisp.net', '$2y$10$w4zMq7ij7NmVDeBBKDSmbu963EwchZwAHPZmgZmTQAQ8Gha2jTD5W', '2017-12-16 20:16:40', '2 The Street', '', 'Townsville', 'USA', 'CA12345', '', '0', 0), +(30, 'Mr', 'Terry', 'Fide', 'tfide@myisp.de', '$2y$10$lePdxFz7ZKn/bJ41BS0h/ehWyIL2ZgK123iPQJahNCaRjgxVY3Rfq', '2017-12-29 11:28:43', '2 The Street', 'The Village', 'Townsville', 'Germany', 'BL1234', '', '0', 0), +(31, 'Miss', 'Dee', 'Jected', 'djected@myisp.org.uk', '$2y$10$ujpV7w4blsTdQFWOsE1fiOFYtj9zN4w0WcK5V4WJ60Pc5HWodWlGC', '2017-12-29 11:48:04', '3 The Street', 'The Village', 'Townsville', 'UK', 'EX3 1TH', '', '0', 0), +(32, 'Mr', 'James', 'Smith', 'jsmith@myisp.co.uk', '$2y$10$Yu.c/cw/TSFa9vcMBGAfAe5vzyOwp3SZarBVc/9vEksfp.F8BzSiW', '2017-12-29 11:58:51', '2 The Street', '', 'Townsville', 'UK', 'EX24 6PS', '01234777888', '0', 0); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `art` +-- +ALTER TABLE `art` + ADD PRIMARY KEY (`art_id`), + ADD KEY `art_name` (`thumb`,`price`); + +-- +-- Indexes for table `artists` +-- +ALTER TABLE `artists` + ADD PRIMARY KEY (`artist_id`); + +-- +-- Indexes for table `orders` +-- +ALTER TABLE `orders` + ADD PRIMARY KEY (`order_id`), + ADD KEY `buyer_id` (`buyer_id`,`order_date`); + +-- +-- Indexes for table `order_contents` +-- +ALTER TABLE `order_contents` + ADD PRIMARY KEY (`content_id`); + +-- +-- Indexes for table `order_details` +-- +ALTER TABLE `order_details` + ADD PRIMARY KEY (`ord_details_id`), + ADD KEY `order_id` (`order_id`,`art_id`,`dispatch_date`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`user_id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `art` +-- +ALTER TABLE `art` + MODIFY `art_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36; + +-- +-- AUTO_INCREMENT for table `artists` +-- +ALTER TABLE `artists` + MODIFY `artist_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; + +-- +-- AUTO_INCREMENT for table `orders` +-- +ALTER TABLE `orders` + MODIFY `order_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `order_contents` +-- +ALTER TABLE `order_contents` + MODIFY `content_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; + +-- +-- AUTO_INCREMENT for table `order_details` +-- +ALTER TABLE `order_details` + MODIFY `ord_details_id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `user_id` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Ch11/paypalcart/process_add_painting.php b/Ch11/paypalcart/process_add_painting.php new file mode 100644 index 0000000..3fa5d8c --- /dev/null +++ b/Ch11/paypalcart/process_add_painting.php @@ -0,0 +1,120 @@ +The painting was successfully registered
    '; + } else { // If it was not registered + // Error message: + echo '

    System Error

    +

    The painting could not be added due to a system error. We apologize for any inconvenience.

    '; + // Debugging message: + // echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection. +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Add Painting | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Add Painting Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Add Painting Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Add Painting | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Add Painting Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Add Painting Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display the errors. + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Print each error. + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if (empty($errors)) +?> \ No newline at end of file diff --git a/Ch11/paypalcart/process_admin_page.php b/Ch11/paypalcart/process_admin_page.php new file mode 100644 index 0000000..9e83197 --- /dev/null +++ b/Ch11/paypalcart/process_admin_page.php @@ -0,0 +1,91 @@ +The artist was successfully added.'; + } else { // If the query failed to run + // Message: + echo '

    System Error

    +

    The artist could not be added due to a system error. '; + echo 'We apologize for any inconvenience.

    '; + // Debugging message: + //echo '

    ' . mysqli_error($dbcon) . '

    Query: ' . $q . '

    '; + } // End of if ($result) + mysqli_close($dbcon); // Close the database connection + } +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Admin Page | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Admin Page Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Admin Page Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Admin Page | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Admin Page Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Admin Page Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} + } else { // Display any errors + echo '

    Error!

    +

    The following error(s) occurred:
    '; + foreach ($errors as $msg) { // Display any errors + echo " - $msg
    \n"; + } + echo '

    Please try again.


    '; + }// End of if error checks +?> \ No newline at end of file diff --git a/Ch11/paypalcart/process_forgot.php b/Ch11/paypalcart/process_forgot.php new file mode 100644 index 0000000..a9cd4a7 --- /dev/null +++ b/Ch11/paypalcart/process_forgot.php @@ -0,0 +1,77 @@ +If your e-mail and secret are correct, you will recieve an e-mail'; + } + } + if ($buyid) { // If buyid for the email address was retrieved, create a random password + $password = substr ( md5(uniqid(random_int(), true)), 5, 10); +// Update the database table + $hassed_password = password_hash($password, PASSWORD_DEFAULT); + $query = "UPDATE users SET password=? WHERE user_id=?"; + $q = mysqli_stmt_init($dbcon); + mysqli_stmt_prepare($q, $query); + // bind $id to SQL Statement + mysqli_stmt_bind_param($q, "si", $hassed_password, $buyid); + // execute query + mysqli_stmt_execute($q); + if (mysqli_stmt_affected_rows($q) == 1) { +// Send an email to the buyer + $body = "Your password has been changed to '" . $password; + $body .= "'. Please login as soon as possible using the new password. "; + $body .= "Then change it immediately. otherwise, if a hacker has intercepted "; + $body .= "this email they will know your login details."; + mail ($email, 'Your new password.', $body, 'From: admin@thedovegallery.co.uk'); +// Echo a message and exit the code + echo '
    Your password has been changed. '; + echo 'You will shortly receive the new temporary password by email.
    '; + mysqli_close($dbcon); + include ('includes/footer.php'); + exit(); // Stop the script. + } else { // If the query failed to run + echo '

    Due to a system error, your password could not be changed. We apologize for any inconvenience.

    '; + } + } + mysqli_close($dbcon); + } + catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Forgot Password | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Forgot Password Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Forgot Password Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Forgot Password | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Forgot Password Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Forgot Password Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/paypalcart/process_found_pics.php b/Ch11/paypalcart/process_found_pics.php new file mode 100644 index 0000000..063fbf9 --- /dev/null +++ b/Ch11/paypalcart/process_found_pics.php @@ -0,0 +1,84 @@ + 0) { + +//$result = mysqli_query( $dbcon, $q ) ; +//if ( mysqli_num_rows( $result ) > 0 ) +//{ +// Table header +?> + + + + + + + + + + + + + + + + + '; + } +?> +
    ThumbTypeMediumArtistDetailsPrice £Add to Cart
    ' . $type . '' . $medium . '' . $artist . '' . $mini_descr . '' . $price . + '
    Add to Cart
    +There are currently no items matching your search criteria.

    ' ; } +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Found Pics | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Found Pics Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Found Pics Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Found Pics | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Found Pics Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Found Pics Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/paypalcart/process_login.php b/Ch11/paypalcart/process_login.php new file mode 100644 index 0000000..d9ebc34 --- /dev/null +++ b/Ch11/paypalcart/process_login.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/Ch11/paypalcart/process_register.php b/Ch11/paypalcart/process_register.php new file mode 100644 index 0000000..e0cbaaf --- /dev/null +++ b/Ch11/paypalcart/process_register.php @@ -0,0 +1,197 @@ +error; +// change to generic message in production + } + }else{//The email address is already registered +echo '

    The email address is already registered

    '; +} + } else {//End of SUCCESSFUL SECTION +// ---------------Process User Errors--------------- +// Display the users entry errors +echo '

    Error!

    +

    The following error(s) occurred:
    '; +foreach ($errors as $msg) { // Print each error. +echo " - $msg
    \n"; + } +echo '

    Please try again.


    '; + }// End of if (empty($errors)) IF. +mysqli_close($dbcon); +} +catch(Exception $e) +{ + print "The system is busy, please try later"; + $error_string = date('mdYhis') . " | Registration | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/exception_log.log"); + //error_log("Exception in Register Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Register Exception" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Exception occurred. Message: " . $e->getMessage(); +}catch(Error $e) +{ + print "The system is busy, please come back later"; + $error_string = date('mdYhis') . " | Registration | " . $e-getMessage() . "\n"; + error_log($error_string,3,"/logs/error_log.log"); + //error_log("Error in Register Program. Check log for details", 1, "noone@nowhere.com", + // "Subject: Register Error" . "\r\n"); + // You can turn off display of errors in php.ini display_errors = Off + //print "An Error occurred. Message: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/Ch11/paypalcart/register.php b/Ch11/paypalcart/register.php new file mode 100644 index 0000000..4f2e901 --- /dev/null +++ b/Ch11/paypalcart/register.php @@ -0,0 +1,243 @@ + + + + + Template for an interactive web page + + + + + + + + + +
    + +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    +

    Account Registration

    +
    Items marked with an asterisk * are essential
    +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > + Between 8 and 12 characters. +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + " > +
    +
    +
    + +
    + +
    +
    +
    + +
    + " > +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/register_thanks.php b/Ch11/paypalcart/register_thanks.php new file mode 100644 index 0000000..2737ead --- /dev/null +++ b/Ch11/paypalcart/register_thanks.php @@ -0,0 +1,40 @@ + + + + + Template for an interactive web page + + + + + + + +
    + +
    + +
    + +
    +
    + +
    +

    Thank you for registering

    +
    You will now be able to login, search for, and view the paintings. +Even without logging in you can view and search the gallery, +but if you login you can see an enlarged version of each painting
    +
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/Ch11/paypalcart/transparent.css b/Ch11/paypalcart/transparent.css new file mode 100644 index 0000000..a21422c --- /dev/null +++ b/Ch11/paypalcart/transparent.css @@ -0,0 +1,15 @@ +body { background:#68CE53; font-family:arial; font-size: 100%; +} +header {border:10px white solid;} +#container { + margin:auto; +} +h2 { margin-top: 20px; } +label { color: black; } +#submit {margin: 0px; background:#559a55; border: 5px outset #559a55; width: 140px;} +#includemenu {padding-top: 10px; padding-bottom: 10px; padding-right: 0px;} +#includefooter {background:#68CE53; padding-top: 5px; padding-bottom: 5px; margin: 0px;} +#includeheader {width:90%; height:auto; background:#95b522; margin-bottom: 0px; padding:0px;} +#contents {background-color:transparent ;margin-top: -17px; border:10px white solid; color: white; width: 90%; } +#buttons {background:#559a55; border: 5px outset #559a55;} + diff --git a/Ch11/paypalcart/users_search_page.php b/Ch11/paypalcart/users_search_page.php new file mode 100644 index 0000000..564010d --- /dev/null +++ b/Ch11/paypalcart/users_search_page.php @@ -0,0 +1,69 @@ + + + + +The registered user's search page, custom cart version + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +

    Welcome to the Dove Gallery

    +

    All prices include frames, sales tax, delivery and insurance

    + +
    + Type
    +
    + Maximum Price
    +
    +

    +
    +
    +
    +

    Copper Kettle by James Kessell 

    +
    +
    +
    +
    +
    + + diff --git a/Contributing.md b/Contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/Contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..dbf0a0a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2018 Adrian West and Steve Prettyman + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d07d5c --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Apress Source Code + +This repository accompanies [*Practical PHP 7, MySQL 8, and MariaDB Website Databases*](https://www.apress.com/9781484238424) by Adrian West and Steve Prettyman (Apress, 2018). + +[comment]: #cover +![Cover image](9781484238424.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +## Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +## Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. \ No newline at end of file diff --git a/errata.md b/errata.md new file mode 100644 index 0000000..11e10af --- /dev/null +++ b/errata.md @@ -0,0 +1,13 @@ +# Errata for *Book Title* + +On **page xx** [Summary of error]: + +Details of error here. Highlight key pieces in **bold**. + +*** + +On **page xx** [Summary of error]: + +Details of error here. Highlight key pieces in **bold**. + +*** \ No newline at end of file