Wiley
Wiley.com
Print this page Share

PHP and MySQL: Create - Modify - Reuse

ISBN: 978-0-470-19242-9
341 pages
May 2008
PHP and MySQL: Create - Modify - Reuse (0470192429) cover image
Learn everything about the dynamic power of PHP and MySQL in real-world applications with the practical information and step-by-step instructions in PHP and MySQL: Create - Modify – Reuse. The authors, experts in tune with common web development tasks, will guide you through several projects that are complete, tested, and ready to be implemented, so that you can understand by doing. Understand all aspects of design, such as portability, design flow, and integration, and become proficient at solving problems that developers face in everyday circumstances.
See More

Introduction xi

Chapter 1: User Registration 1

Plan the Directory Layout 1

Planning the Database 2

Writing Shared Code 3

User Class 5

CAPTCHA 9

Templates 11

Registering a New User 12

E-mailing a Validation Link 17

Logging In and Out 21

Changing Information 25

Forgotten Passwords 28

Summary 30

Chapter 2: Community Forum 31

Design of the Forum 31

Designing the Database 32

Working with Permissions and Bitwise Operators 33

Updating the User Class 35

Code and Code Explanation 40

Adding Forums 41

Adding Posts 43

Displaying Forums and Posts 47

Pagination 55

Avatars 56

BBCode 59

Summary 62

Chapter 3: Mailing List 63

Design of the Mailing List 63

Choosing POP3 64

Designing the Database 65

Code and Code Explanation 66

The POP3 Client 66

The Configuration File 73

Account Management 73

Processing Messages 79

Processing the Digest 83

Setting Up the Mailing List 83

Summary 86

Chapter 4: Search Engine 87

Designing the Search Engine 87

Problems with Full-Text Search 88

Designing the Database 89

Code and Code Explanation 91

Administrative Interface 91

Crawler/Indexer 98

Front End 104

Summary 110

Chapter 5: Personal Calendar 113

Designing the Application 113

Designing the Database 114

Code and Code Explanation 115

Creating a Month-View Calendar 115

Creating a Day-View Calendar 120

Adding and Showing Events 121

Sending Reminders 129

Exporting the Calendar 130

Summary 135

Chapter 6: Ajax File Manager 137

Design of the Ajax File Manager 137

JavaScript and Ajax 138

The XMLHttpRequest Object 139

Code and Code Explanation 142

Main Interface 143

Client-Side Functionality 147

Server-Side Functionality 160

Summary 175

Chapter 7: Online Photo Album 177

Design of the Online Photo Album 177

Code and Code Explanation 178

Views 178

Helper Files 188

QuickTime Thumbnails 190

Thumbnail Caching 192

Summary 193

Chapter 8: Shopping Cart 195

Designing the Shopping Cart 195

Designing the Database 196

Code and Code Explanation 197

The ShoppingCart Class 197

Working with the Shopping Cart 201

Building the Storefront 209

Adding Inventory 217

Summary 238

Chapter 9: Web Site Statistics 239

Determining What to Collect 239

Designing the Database 241

Obtaining Data 242

Code and Code Explanation 244

Pie Chart 244

Bar Chart 248

The Report 253

Summary 264

Chapter 10: News/Blog System 265

Tables 265

Adding Posts 267

Generating the RSS 278

Displaying Posts 282

Adding Comments 285

Summary 289

Chapter 11: Shell Scripts 291

Designing the Script 292

General Shell Scripting Advice 293

Code and Code Explanation 294

The CommandLine Class 294

startproject 303

The Skeleton 313

Summary 314

Chapter 12: Security and Logging 315

Cross-Site Scripting 315

Path Traversal 318

Injection 320

SQL Injection 320

Command Injection 324

Weak Authentication 325

Logging 327

Preventing Accidental Deletes 330

Summary 332

Index 333

See More
Timothy Boronczyk is a native of Syracuse, NY, where he works as a freelance developer, programmer and technical editor. He has been involved in web design since 1998 and over the years has written several articles and tutorials on PHP programming. Timothy holds a degree in software application programming and recently started his first business venture, Salt City Tech ( www.saltcitytech.com ). In his spare time, he enjoys photography, hanging out with friends, and sleeping with his feet hanging off the end of his bed. He ’ s easily distracted by shiny objects.

Martin E. Psinas is a recognized security expert and valued member of the open - source community. He has been contracted as a technical editor, code auditor, and is a published author with Pearson Education as well as the #1 PHP magazine, PHP|Architect . In his free time, he maintains his personal web site and is a volunteer administrator/contributor at codewalkers.com — a resource for PHP & MySQL developers. Martin interacts frequently with the leaders of the PHP project as well as PHP User ’ s Groups.

See More
Download TitleSizeDownload
README FIRST 1.47 KB Click to Download
Chapter 1 12.46 KB Click to Download
Chapter 2 25.12 KB Click to Download
Chapter 3 10.00 KB Click to Download
Chapter 4 8.25 KB Click to Download
Chapter 5 8.81 KB Click to Download
Chapter 6 23.60 KB Click to Download
Chapter 7 34.67 KB Click to Download
Chapter 8 17.77 KB Click to Download
Chapter 9 6.67 KB Click to Download
Chapter 10 735.60 KB Click to Download
Chapter 11 4.09 KB Click to Download
Chapter 12 4.61 KB Click to Download
All Code for Book 888.44 KB Click to Download
See More

Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.

ChapterPageDetailsDatePrint Run
Error in Code
login.php Line 21:

if ($user->userId && $user->password == sha1($_POST['password']))

Should be

if ($user->userId && $user->isActive && $user->password == sha1($_POST['password']))
10/14/09
Error in Code
Chapter 1, User Registration, the forgotpass.php file:

// store new password
$user->password = $password;
$user->save();

Should be:

// store new password
$user->password = sha1($password);
$user->save();
10/14/09
48 Error in Text
echo htmlspecialchars($row['DESCRIPTION']) . '</li>';

Should be:

echo htmlspecialchars($row['DESCRIPTION']) . '</a></li>';

This appears again on page 53 as view.php and should be corrected there as well.
11/23/09
49 Error in Text
echo htmlspecialchars($row['SUBJECT']) . '</li>';

Should be:

echo htmlspecialchars($row['SUBJECT']) . '</a></li>';

This appears again on page 53 as view.php and should be corrected there as well.
11/23/09
69 Error in Text
Lower gray box on page:

$p->connection

should be

$p->connect
11/23/09
77 Error in Text
manage.php code line 11 left off semicolon at the end of the line

The line should be:

$pop->user(MANAGE_USER);
11/23/09
79 Error in Text
The case 'HELP' block needs to have a break statement

The code should read:

case 'HELP':
$response_file = 'help.txt';
break;
11/23/09
129 Error in Text
The section "Sending Reminders"
The notify.php code in the gray box

The 7th line down is missing ending single quote on the actual email address.
This is wrong in the book and in the download code.
(note the download code has different email address,
but they still forgot the single quote at the end).

in the book
Code:
define('EMAIL_ADDR', 'tboronczyk@example.com);
and in the download code
Code:
define('EMAIL_ADDR', 'tboronczyk@gmail.com);
It should be like
Code:
define('EMAIL_ADDR', 'tboronczyk@example.com');

1/14/10
130 Error in Text
notify.php, in the first gray box where it says mail,

mgs should be msg. This is wrong in both the book and download code

The book has it like this.
Code:
mail(EMAIL_ADDR, "Reminders for $month/$day/$year $hour:$minute $am", $mgs);
It should be like this, (msg instead of mgs)
Code:
mail(EMAIL_ADDR, "Reminders for $month/$day/$year $hour:$minute $am", $msg);
1/14/10
222 Error in Text
The last word in paragraph 1 on p.222 is SystemOverflowException.
This should read System.StackOverflowException, as this is the error thrown at runtime when compiled code contains an infinite loop between two class constructors.
2-16-11
11 309 Error in Code
Reads: STEDRR.

Should be: STDERR
11/09/2010
320 Code Error
On page 320, at the top of the page there is a gray box section containing code,
The variable $target is not defined (line 10); This will give you an error.
The code should contain $template, not $target, on page 320. The correct code excerpt should be:
<?php define(TEMPLATE_DIR, '/srv/apache/example/templates/');
if (isset($_GET['t']))
{
$template = realpath(TEMPLATE_DIR . $_GET['t']);
}
if (isset($template) && strpos($template, TEMPLATE_DIR) !== 0 && file_exists($template)),
{
include $template;
}
else
{
include TEMPLATE_DIR . 'default.php';
}
?>
2-16-11
323 Error in Code
On page 323, about 12 lines down, there is a gray box illustrating a line of code. The sample should read:
$query = sprintf('SELECT USERNAME, EMAIL_ADDR FROM WROX_USER WHERE ' .
'USER_ID = %d', $_POST['userid']);
2-16-11
See More
Buy Both and Save 25%!
+

PHP and MySQL: Create - Modify - Reuse (US $39.99)

-and- Beginning SharePoint Designer 2010 (US $34.99)

Total List Price: US $74.98
Discounted Price: US $56.23 (Save: US $18.75)

Buy Both
Cannot be combined with any other offers. Learn more.

Related Titles

Back to Top