Update user.php

Added comments to code. Also removed a duplicate function.