Why PHP_SELF Should Be Avoided When Creating Website Links

When looking for articles about PHP_SELF, it seems like most only refer to the dangers of using the variable with HTML forms. However, there are risks with using it in other parts of a website. For example, it may be tempting to use the variable within the href attribute for links. The problem is that those links become susceptible to Cross-Site Scripting (XSS). Let's take a closer look at the security vulnerability of PHP_SELF and a simple alternative to avoid the problem altogether. [Continue reading]

How to Disable (or Modify) the Revision History in WordPress

For some reason, WordPress maintains the revision history for posts in the same database as the live posts. The issue with having the revision posts in the database is the extra overhead. Whenever the website queries the database, it needs to work with all records—including the revisions. Of course, this will unlikely be a problem for most blogs. But for those who prefer to keep websites running as efficiently as possible, the number of revisions can be limited…or stopped altogether. [Continue reading]

Using Google Analytics to Determine Which Browsers Are Used Most for Accessing Your Website

When designing websites, it's important to have a general idea of which browsers your audience prefers. Knowing this helps identify which browsers to use for testing your website. Some coding solutions may also need to be altered. For example, if 60% of visitors are still using Internet Explorer 6, you might need to rethink some of those fancy CSS techniques. So let's look into utilizing Google Analytics to figure out which browsers are being used. [Continue reading]

Making HTML Forms More Accessible and Improving Usability with the Label Tag

It's surprising that there are still HTML forms online not taking advantage of the <label> tag. In addition to being required for creating accessible forms, <label> tags improve the usability of forms. For example, instead of forcing visitors to click those tiny radio buttons, why not let them to click the text label. [Continue reading]

Generate Usernames with JavaScript: Working with Short Last Names

When generating usernames, one thing to consider is the length of the username. The code from last week's post may be problematic if you're looking for the username to be five characters or more and the user's last name is only two characters. After tacking on the first initial, you would only have three characters. So let's look at getting closer to the desired results. [Continue reading]

Using JavaScript to Dynamically Generate the Username within an HTML Form

Usernames are typically made up of some combination of the user's first and last name. If that's the case, the form used to create those usernames could be modified to take advantage of the data in the first and last name fields. Instead of making someone manually type the username, JavaScript could be employed to generate it automatically. [Continue reading]

Using Internet Explorer 9 to Test Websites with IE8 and IE7

Did you know that Internet Explorer 9 (IE9) provides the capability for viewing websites in IE8 and IE7? There's no need to install an add-on or download anything from a browser archive. The power to test websites using all three versions of Internet Explorer is built in. Of course, the feature for switching between the different options is a little buried. [Continue reading]

Using the Date Format Chosen by the User Instead of Hard-Coding Your Own in the WordPress Theme

WordPress has a setting under the admin panel where blog owners can indicate how dates should be displayed for blog posts and comments made to the blog. The setting isn't very useful though when the date format is hard coded into the theme. Instead of making users edit the theme files, let's take advantage of the WordPress setting. [Continue reading]

Choosing the Date Format in WordPress Themes: Let’s Give Control Back to the User

So many WordPress themes have the date format hard coded into the theme files. The problem is that some users will prefer to display the date in another way. Maybe the chosen format doesn't match their organization's style guidelines or maybe the format isn't grammatically correct. Changing a hard-coded date requires users to dig through file after file to modify every instance. Plus, if the theme developer releases an update, the user may need to do it all over again. To save users the hassle, why not let them decide how the dates are displayed. There is a setting in WordPress after all. [Continue reading]

Do Single-Quoted Strings Cause More Harm Than Good in PHP?

When writing PHP code, is it better to use single or double quotes? Using single quotes wherever possible will improve the performance of your code, but does it cost too much in productivity when less experienced developers work with the code? After all, certain things won't work as some might expect when using single quotes, such as variables inside the string. [Continue reading]