A couple of notes, sanizite your request variables before pulling data directing into you code. Avoid using double quote for simple string echo as it is extra load on php parsing   use single quote instead. Play with MVC type frameworks such as Zends framework to get familiar with design patterns. Nice tutorial for beginners but be warned, I had to fire a bunch of people recently who programmed like this   go back to programming basics and learn popular framework methodologies.