The blog is being migrated and merged with multiple Imphenzia blogs so the format and content will be inconsistent for a while.

Protecting the site & AJAX

It's been  a long time since I've spent so many hours on something producing such a small visible result. First of all I had to learn all about protecting PHP code and form fields that are inserted into the database when logging in with mysql_real_escape_string and the joys of some servers having magic_quotes_gpc enabled and when stripslashes should and shouldn't be used. I've finally protected the code enough from malicious visitors - I don't want to end up like the old imphenzia forums once were if you remember those days. Since I already developed the login / logout / remember me features of the new sites yesterday, the 4 hours I spent on just protecting the code was just plain boring - but not wasted as the result is good and I learned something very useful.

Originally I used a javascript called "Live Validation" to verify the contents of form fields as you type in them and the result was quite cool - what it didn't support, however, was verifying on the fly that a username already existed or if invalid characters were entered. A friend of mine advised me about AJAX (Asynchronous JavaScript and XML) and this is something I find very exciting (sadly enough!). What AJAX enabled me to do (amongst a million other things) is to verify if a username exists in the database as a user is typing into the form field. If the user enters a username while registering that already exists, the web page will warn you that the name is taken - this all without submitting the form or using the tedious back button etc. Now then you might think - why waste so much time on learning this stuff as I may never have a huge amount of registered users on imphenzia.com - but my reply is that learning this stuff is extremely useful as fast and intelligent websites is the future.

I found out that when troubleshooting javascripts, FireFox with the extension 'firebug' is very useful for debugging when things go wrong. Firebug will display error messages and scripts neatly and in my case the AJAX feed that is returned. At the same time, I must admit that I very much prefer IE as a browser - mainly because it renders web pages much nicer and - and also because so many sites look incorrect in FireFox... and if you are a true FireFox fan you will probably explode now and say that all these sites look horrible because they were incorrectly developed, the fact is that they still look horrible regardless of who's fault it is hence me prefering IE :)

Well, I still have some work left to do with the validation method tomorrow and the easter weekend is nearly over. Once validation is finally taken care of I can move on to more fun stuff on the site such as the music section.

Working on a new splash

Since the new blog is launched, I've spent some time working on a new updated splash screen for www.imphenzia.com that will feature 4 sections instead of the current two. These will be music and games that you all recognize from before, but also the forum and the new blog. I am also slowly learning how to create sites using CSS instead of traditional HTML. CSS is a great method to position page elements and get efficient code with different styles, but at the same time it is a bit of a headache due to browser compatibility as different browsers choose to interpret the code in different ways. One example is vertical alignment, it used to be a 1 row job in traditional HTML using tables, but in CSS there is about 30 lines of code and you still don't get a cross browser compatible result... when you google about this most people will blame IE, but regardless of who to blame I just want it to work :)

Once I've learned CSS a bit better I will also redo the music and the game sites to look more up to date as the design is getting quite dated. The new splash screen should be up and running soon. Now it's time to watch another episode of Life on Mars with my wife and a cup of tea.