I suppose it goes here, as it's the web and it's about web design, if not please move it.. I wasn't sure where to go
Anyway,
Can someone come up with some guidelines to good practice for coding please? As i've been coding for a while, but i know its not normally with good practice.
Techspot is primarily systems management, not programming. There are a few of us
with programming backgrounds, but you would be well advised to look elsewhere,
especially given the broad question you ask -- it's a field of study unto itself
Search by keywords for common CGI languages. Try PHP, Perl, Python, Ruby
Of course, that statistic is somewhat offset because PHP is the most common CGI language and usually the thing that inexperienced people start off with..
Anyway.. Since you are asking the question, you probably aren't capable of producing proper documentation for your projects (UML diagrams and stuff). What you can do is commenting it properly. The ideal case would be that someone reading only your comments would be able to produce code with the same functionality as yours.
PHP indenting conventions should be explained in any PHP book/guide/tutorial.