Updated sample code to be more PHP and less Javascript :)