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.
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.
[...] IMPHENZIA BLOG wrote an interesting post today on Protecting the site & AJAXHere’s a quick excerptSince 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 - … Once validation is finally taken care of I can move on to more fun stuff on the site such as the music section…. [...]
ReplyDelete