@guineacode - You're welcome! Since software development (like all human progress) is collaborative I believe that credit should be given where it's due.
@rookie - Since this is client-side code (all happening in the web browser) no requests are ever sent to a server for processing so no PHP code is invoked. It sounds like you're building a more traditional facebook app where the user is redirected after login to a URL on your server for processing. You should probably read the Server-side Flow section of Authentication. If you still have questions you should try Facebook's Stackoverflow site.

Updated so that the Facebook script loaded handler is hooked up before the script tag is inserted.
Noted that if your app is in sandbox mode login will not work correctly (it's how Facebook works or a bug depending on your point of view).
Added another redirect URL as an example of hot redirect a Facebook app compared to a website that uses Facebook login.