Added invite checking in register

Added invite checking and error handling in register schema
Fixed mysql NULL return bug

Fixed mysql NULL result bug