moreHawes Through Time
Since I have been working on updating this site recently I thought I would delve into the history books (not really that far back) and look at the previous versions of my website.
Although slightly pointless, I have spent a fair bit of time making these so it’s nice to remember.
Version 1
Between around 2004 – 2005, I made this site before I even knew what programming really was, but that didn’t stop me wanting to be a web designer!

The site consisted of a simple 5-page site with a few fancy animated graphics. Still now I like how this site looks.
Version 2
Around 2005 – 2007. I knew a bit of PHP by now and decided that a new site was in order! Re-inventing the wheel slightly I write some scripts for comments, a basic forum and a few other twiddly bits.

Version 3
Around 2007 – 2008. Enter Drupal! I quickly realised the potential of using a content management system, though at this stage I was using it pretty much out of the box.

Version 4
2009 – 2010! Still using Drupal but heavily customised with my own theme. I have organised my content in more of a blog style with all sorts of fancy witchcraft working behind the scenes.

Version 5
2010 – present. Hello Wordpress! A complete re-write, re-design and migration to Wordpress. Since starting to use Wordpress it quickly because my CMS of choice with it’s long features list and great community support. It’s a tool that really makes publishing on the web a hassle-free task.

Tags: Internet • Me • Wordpress
Nochex Steal Your Money
For a client recently I had to test osCommerce was accepting Nochex payments. Having never used it before I went through the lengthy and painful process of signing up for a Nochex account.
Well now I know why no one used Nochex. It’s rubbish. It’s the only thing that would make me recommend Paypal (and I hate Paypal) to anyone but at least their service does what it is supposed to with minimum fuss.
OsCommerce was working fine and accepted my Nochex account but Nochex wouldn’t accept my address, so I was unable to put a card straight through (as a user without an existing Nochex account might). So I gave up on that as the client offers their own credit card gateway.
So I thought that was that – but when you add a credit/debit card to Nochex they debit a ’small’ amount from your card to help with their verification process. They didn’t go out of their way to tell you this when you register and they certainly don’t make it clear enough that this is non-refundable!
So there I was waiting for my couple of quid to get refunded only to discover it has been stolen. And for what? … other one for ‘the list’
Tags: 1 • Boycotts • Dislikes • Me • e-commerce • osCommerce
Easily Generate Javascript and PHP Error Checking For Your Forms
I wanted a quick and easy way of adding Javascript and PHP error checking to my form elements. The benefit of this is that errors can be caught using Javascript before the form is submitted, but if JS is disabled in the users browser then the error is still caught using PHP.
The method I came up with to solve this is very simple and can be easily added to form elements with little extra code. The error checking is done by checking input against regular expressions.
See the demo and demo source code.
Code Explaination
One function is used to create both forms of error checking:
<?php $jsChecks = ""; //holds JS error checks $errorFound = false; //PHP error flag //Creates both JS and PHP error checks function errorCheck($elementName, $regExp, $errMsg) { global $jsChecks; global $errorFound; //Create Javascript error checking $check = ' var ' . $elementName . 'Filter = ' . $regExp . '; if (!' . $elementName . 'Filter.test(theForm.' . $elementName . '.value)) { errorMessage += "\n * ' . $errMsg . '"; errorFound = true; }' . "\n"; $jsChecks .= $check; //PHP error checking and return input class if(isset($_POST["formSubmitted"])) { //if form submitted if(!preg_match($regExp, $_POST[$elementName])) { $errorFound = true; return "error"; //css error class } } return ""; //no class if no error detected }
Error checking is created for the form elements specifying which element (by name), a regular expression to be checked against and a custom error message:
//Create error checking $nameError = errorCheck("name", "/([a-z0-9]{3}[a-z0-9]?)/", "Name is too short"); //Must be 3 chars or over $emailError = errorCheck("email", "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i", "Invalid Email Address"); //must be valid email address
If no error is found then process the data.
//If no error found if(!$errorFound) { //Process form data... } ?>
In our head tags we add the following Javascript and CSS rules. The Javascipt checks we created for each element are included here by the PHP ehco:
<style type="text/css"> input { border: 1px solid #DDD; } .error { border: 1px dashed #F00; } </style> <script type="text/javascript"> <!-- function validateForm(theForm) { var errorFound = false; var errorMessage = "Please correct the following errors:\n"; <?php echo $jsChecks ?> if(errorFound) { alert(errorMessage); } return !errorFound; } //--> </script>
The form is really simple with code to display a CSS class depending on whether a error is detected (for the PHP error checking) and to set the value of the field:
<form method="post" onSubmit="return validateForm(this)"> <label for="name"><strong>Name</strong> (must be 3 characters or over)</label><br /> <input type="text" name="name" id="name" size="30" class="<?php echo $nameError ?>" value="<?php echo @ $_POST['name'] ?>" /><br /> <label for="email"><strong>Email Address</strong> (must be a valid email address)</label><br /> <input type="text" name="email" id="email" size="30" class="<?php echo $emailError ?>" value="<?php echo @ $_POST['email'] ?>" /> <br /> <input type="hidden" name="formSubmitted" id="formSubmitted" value="true" /> <input type="submit" value="Submit" /> </form>
There you are, both Javascript and PHP error checking! See the complete source code here.
Tags: Javacsript • PHP • Programming • Web Development
Magento Theme / Templating Tutorials, Guides and Resources
I think anyone that has worked with Magento will agree that it is a steep learning curve, this is not helped by the lack of documentation. I have put together a list of useful links when that I found helpful whilst trying to get my head around Magento themes:
(I have expanded upon these lists which I found useful)
- Php|architect’s Guide to E-Commerce Programming with Magento
- Designer’s Guide to Magento – The most solid of Magento’s documentation, though it might take a few reads before things become clear! (pdf version)
- The Magento API
- Magento Screencasts
- Designing for Magento Webinar – worth watching the wmv file as much better quality
- Magento Wiki – out dated but some handy concepts
- Ohminu forum post – the lead designer breaks things down for newbies
- Magento Folder Structure
- Changing Text – using the Locale File
- Builing Blocks – more handy hints from the lead designer
- Screencast on creating themes – a very brief introduction to creating a new theme
- Video’s and other resources from php | architect
Tags: Magento • Web Development • e-commerce
