the reason for redirecting is the number you have to send with the login-function. it says to wich page to redirect. you might have to change that.
to get the pm's, i think it should be something like this:
this will select all pm's from a specified user. to restrict to only the not read messages, i have no idea. i looked in a db backup of a phpbb forum, but i couldn't find anything about the status of a pm (read / not read).
[EDIT]: i think i just found it

. they work with a system of last-login. and they see if there's a message posted after the last time you have logged in. it should look like this:
you might want to take a look on the phpbb forum.
Greetz,
UnrealEd