Archive for July 8th, 2006

WeberDev.com: PHP 101 (part 13): The Trashman Cometh

WeberDev.com has just added to their popular “PHP 101″ series today with the release of part 13 - “the Trashman Cometh”.

Over the next few paragraphs, I’m going to show you some basic tricks to validate user input, catch “bad” data before it corrupts your calculations and databases, and provide user notification in a gentle, understandable and non-threatening way. To prepare for this exercise, I suggest you spin up a CD of John Lennon singing “Imagine”, fill your heart with peace and goodwill towards all men, and take a few deep, calming breaths. Once you’ve exhaled, we can get going.

They prepare you for the “wonderful” world of input validation by means of form validation examples (one of the most common ways users could abuse your site). They cover checking for things like:

  • No value entered
  • Value entered is invalid/empty
  • A date entered isn’t valid
  • Using regular expressions

They also touch on a few other validation methods before wrapping it up with some more complete code examples and explainations.

Continue Reading · Add comment

DevShed: Implementing the commit() and rollback() Methods with mysqli and PHP 5

Continuing on with their “mysqli in PHP5″ series, DevShed has posted part two highlighting the commit and rollback functions - their use and functionality.

This is the second part of the series “Using mysqli with PHP 5.” Welcome back. In three tutorials, this series shows how to use the most important methods and properties included in the “mysqli” extension that comes with PHP 5, in order to take advantage of the new features bundled with MySQL 4.1 and above.

In part one they introduced the extension, providing the background for those just joining in. In this latest part, they take it to the next level and talk about these new handy functions - one to save the updates/additions you’re making to the database and the other to undo those changes quickly and easily. As always, there’s plenty of examples, explainations, and code to go around.

Continue Reading · Add comment

PHPit.net: Book Review: Smarty PHP Template Programming and Applications

PHPit.net has posted a pretty positive review of one of Packt Publishing’s latest offerings, “Smarty PHP Template Programming and Applications”.

Smarty is one of the most popular templating systems for PHP, and it offers so much functionality that it certainly deserves its own book. Read on to learn more about this book.

This book is targeted towards two types of people: designers and developers, and it’s hardly surprising that the book has been divided into a designer part and a developer part.

According to the review, the authors - Lucian Gheorghe, Hasin Hayder, Joäo Prado Maia - have put together a good, solid book on using Smarty. The seperation of the designer and developer parts also make it valuable as two books in one. There’s talk of why you should use Smarty, building templates, some real-world examples, and the use of modifiers and functions.

Continue Reading · Add comment

ThinkPHP Blog: Creating press-ready PDF documents on the fly including individual barcodes

In this new post on the ThinkPHP blog, Jason Easter demonstrates how, with the help of the PDFlib library for PHP, you can create “press-ready PDF documents” whenever you need to (including barcodes).

Often people would like to create a PDF in offset quality out of a big bunch of addresses and create a barcode for each address. Sure, you could do this using the serial-letter-function in Word or any PHP library - the problem is that you have to stick to special standards, e. g. using CMYK colorspace and the like.

There may be other good solutions for that. Anyway, now let’s talk about doing that by using PDFLib - in the lite (and therefor free) version.

His example uses the “lite” version of the library and JPGraph to create the barcodes. They create the barcode first (from a value passed in the $_GET string), then insert it into the PDF defined by the code they provide. They even show how to add additional text and an image to round out the look of the newly minted PDF.

Continue Reading · Add comment

Pádraic Brady’s Blog: Patterns for PHP: An Update

On Pádraic Brady’s blog, he gives an update on his “Patterns for PHP” project he’s been working up. He’s made the move from DocuWiki to MediaWiki for the structure of the site.

As part of the migration, I grabbed a very lightweight theme and implemented my own changes to spruce it up and patch some small errors the original authors made. With some new colouring the result is a clean design with an open space feel and just a feather brush of colour.

I even got around to creating a simple logo to replace the text heading! This slew of changes makes all the difference to how the website is presented, and avoids the overly crowded “I’m an encylopedia!” feel of Wikipedia. Time to start moving to a proper domain…

The patterns site has also been populated with some info already - details on four patterns: Singleton, Registry, Factory, and Abstract Factory.

Continue Reading · Add comment