Simple Ajax Unit Converter

I’ve been doing quite a bit with jQuery and Ajax as of late and have not only been impressed at the ease of implementation, but also the snappy and responsive feel that it brings to your web apps.

To demonstrate this I’m going to show you how to make a simple unit converter, which will allow you to convert units of digital storage without having to make a single page refresh.

More …

How to Tell If a Form Has Been Submitted Using PHP

Consider this scenario:

You have a form which submits to itself (e.g. a simple contact form). The first time it loads you don’t want to do anything other that render the form.

However, when a user hits Submit, you want to process whatever data you have received, then re-render the form, including (for example) error messages where appropriate.

More …

How to Detect a Touch Device Using JavaScript

A while back I had to make a navigation menu which played a sound when you moused over the various menu points.

The problem was, that this feature didn’t play nicely with touch devices, as they don’t really have a concept of hover.

What happened instead was that the sound would play when the user selected one of the menu points, but would get cut off as the new page loaded – eurgh!

More …

Simple JavaScript Debugging with Chrome's Console

All too often of late, I have seen people having trouble trying to debug some JavaScript or other.

Some were stumped by the white screen of death which confronted them the minute their script failed silently, whilst others were trying to debug their program using an alert dialogue box (a truly tedious process).

Well, good news it at hand. There is another, more efficient way to do things – with the console.

More …

PHP – header('Location: ...') not working in MAMP

Recently, I was trying to help someone build a simple contact form in PHP.

This person was running everything locally on a MAMP server (Macintosh, Apache, Mysql and PHP) and everything was going swimmingly until we ran into a strange issue: PHP’s header('Location: ...') wasn’t working as expected. In fact, it wasn’t working at all.

This is how we solved the problem.

More …

Display Your WordPress Contact Form in a Lightbox

Recently, a client asked me to have their contact form display in a Lightbox (as opposed to on a separate page). I happily implemented this for them and the end result looked pretty snazzy, so I thought I’d write up how I did it.

More …

Using Cookies with jQuery to Make a Simple Style Switcher

Short for HyperText Transfer Protocol, HTTP is the underlying protocol of the World Wide Web. It is used when a browser requests a web page from a server and it is used when the server responds to the browser’s request. HTTP is also stateless, which means that once a server has sent a page to a browser, it forgets having done so straight away. This can be a problem, for example, if a user has identified themselves in order to access protected pages, or if a user wants to customize some aspect of a website, as the server simply cannot remember a thing about it!

More …

How to Run a Batch File as Admin in Windows 7

This is quite a handy tip I picked up this week when I had a Windows batch file which I needed to run with administrator privileges.

Of course, you can find the file, right click it, select Run as Administrator and do it that way, but if you need to run this file more than a few times, that soon gets to be a pain in the neck.

More …