Object-Oriented Programming – Parents and Children

This post is going to be a somewhat short abstract about the concept of parents and children in object-oriented programming (OOP). The first thing of which people new to OOP need to be aware is that parents and children are are not handled as logical parents and children, they are handled more like biological parents and children. It is best to think of the parent/child relationship in OOP as a concept of “inheritance” rather than a concept of containers and contained elements.

Creating a Header/Footer to be Used on all Pages

I referenced this in a post from a few months ago, but never bothered to expound on it. You cannot use cascading style sheets (CSS) to create headers, footers or menus that will be re-used on all of your pages. Instead, you have to use server-side includes (SSI).

There are a handful of ways to use SSI, and they are available in most all of the Web development languages used today. Although I think the use of repeating headers and footers is somewhat outdated, opting more for using templates that dynamically include your content, I’m going to try to teach you a few ways to include your headers, footers and/or menus on all of your pages.

Avoiding SQL Injection with PHP

This is a very quick tutorial to help people avoid SQL injection with their PHP scripts. It seems all too common that people are writing PHP scripts without considering the fact that someone could easily inject some malicious SQL code that could wreak havoc on an entire Web site.

To put it very simply, for those of you that don’t know what SQL injection is; it’s basically sending SQL code through a script that causes the query to execute unintended commands. Some very good examples of SQL injection can be found in the Wikipedia article.

Here are a few very quick tips to help you avoid SQL injection. Of course, nothing is foolproof, but this should take you a long way.

An introduction to the DOM

In the near future, I plan to write a rather in-depth tutorial explaining how to manipulate the DOM using javascript. Essentially, that tutorial will teach how to properly add and remove elements from your Web pages using javascript. If all goes well, that tutorial will be simple enough for beginners to understand, and will help add a lot of power to your javascript arsenal.

However, before I can get into that, we need to explore and understand the DOM.

XML Vs. Databases

I recently had occasion to consider whether to use XML files or a traditional database when constructing a Web-based application at work. It took a lot of careful consideration and research to decide which way I was going to go.

In the end, I chose to use XML files, and I will explain why.

Why didn’t I think of this?

I saw an interesting article on Yahoo! the other day. It appears that someone at Carnegie Mellon came up with the idea to use a CAPTCHA script to mask e-mail addresses. Basically, they provide you with special link code to put in place of your normal mailto link. You can use the link anyway you want, but the script generates some HTML code automatically that looks similar to:

user<a href="http://mailhide.recaptcha.net/d?k=01quxf658CWzRNQC34kj75Ug==&c=5Sc_I7orZzXLkOX6E7fontrPSKXj6NS2QC0a-5mV5Gk=" onclick="window.open('http://mailhide.recaptcha.net/d?k=01quxf658CWzRNQC34kj75Ug==&c=5Sc_I7orZzXLkOX6E7fontrPSKXj6NS2QC0a-5mV5Gk=', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="Reveal this e-mail address">...</a>@example.com

In the example above, the whole e-mail address would actually be username@example.com, but the rest of the username is obscured by the script. Of course, they also supply you with just the address to the CAPTCHA page, so that you can build your own link any way you want.

The link, in turn, leads to a page with a CAPTCHA script. Once you correctly answer the CAPTCHA question, you’re lead to another page with the complete e-mail address. The script is called Mailhide, and it appears to be a completely free utility. It’s such a simple idea that I can’t believe no one thought of this before.

Pages: