The error is at this line:
if($user){
You are using the
$user
variable, but there is no
$user
variable created yet. That's the reason you get the error. To solve this, you have to create
$user
the way you want. (Or replace it by another variable name if that's what you intended to do. It looks like you might have meant to put
$create
there, but I cannot know that for sure).