it looks like the authenticate user code is before the insert record code.
you will need to make sure the insert record behavior does not redirect and that the authenticate user code is after the insert record code.
the user cannot be logged in until the user has been stored in the database. PHP code is executed top to bottom.
right now, the authenticate user behavior is checking the database for a user that has not been inserted to the database yet.