Fix undefined index on $name

Name variable is only declared if the above condition is met, if it isn't it results in a undefined index notice.