Today I want to talk about regular expressions (usually referred to as regex or regexp). No matter what application you are creating, chances are you will need to parse text in some way. It might be for validating user input or for extracting information from a string of data in some arbitrary format. I have yet to work on any project where regex was not required. Read the rest of this entry »
Online apps usually have a way to set your timezone so that all times are local to you. One common feature many end-users expect is some mechanism that automatically detects when DST is on/off and changes things accordingly. Read the rest of this entry »
Today I want to cover a kind of security issue that is not addressed very often. Just about any book or article aimed at developers has some warning about XSS and SQL injection. Those two attacks are arguably two of the most harmful, but there are certainly other things to be weary of. In this post I will talk about Cross-Site Request Forgeries or CSRF (“see-surf”). Read the rest of this entry »
There’s a lot of talk these days about design patterns. The most talked about pattern in the realm of web development seems to be the MVC pattern, or the Model-View-Controller. It is this pattern that many of the most popular frameworks are built around. Frameworks like symfony, CakePHP and CodeIgniter enforce this pattern and offer tools to help make using it a breeze. Ruby’s famous Rails framework and Perl’s Catalyst also make use of the MVC pattern. So what is the big deal? Should you care? In this post I’m going to briefly try and explain the MVC pattern, why you should use it, and how. Read the rest of this entry »
Yesterday I spent 6 or 7 hours working with the symfony framework. After investigating several other frameworks available, like CakePHP and CodeIgniter, I settled down to work with symfony and I’m glad I did. It has a pretty big learning curve, but the free book is an invaluable resource (I’m actually thinking of buying the printed copy). The framework itself is great, and is built up of some excellent parts like Propel for ORM and Creole for database abstraction. Even if you don’t use symfony, check out those two open-source libraries, they are excellent.
Yesterday’s time was spent both learning the framework and creating the upcoming Outershift website. In 6 hours I learned much and completed a good chunk of the back-end. Considering I started from scratch, I am very pleased with how quickly the project has progressed. So, check out the symfony framework for yourself!
Pagination refers to splitting up a large result set into multiple pages. Probably the most recognized use of pagination is that displayed by Google when you perform a search. As long as there have been applications, there has been a need to paginate. Everything from long documents to search results, it’s something almost every app you use has in common. Considering just how common pagination is, it’s the one thing that seems to trip up many amateur programmers. Today I’m going to go over how to create a simple pagination feature in PHP with data collected from a MySQL database. You can download the sources and example database at the end of the post. Read the rest of this entry »
Almost every website has some sort of members-only area. Anything from a profile system to something as simple as email subscriptions for articles. What every members area has in common is some way for a user to authenticate themselves. Most likely, this is through a username and a password. What I’m going to talk about today is the best practices for storing and handling passwords, since they should never be stored in plain text. Read the rest of this entry »