I don't see anything right off the bat. Are you getting an error message?

The only thing that strikes me odd is this... "if $user or $pass" ...Would think it should be... "if $user AND $pass"