if (empty($password1)) { $this->setFieldError("password1", "Enter the password"); return; } if (empty($password2)) { $this->setFieldError("password2", "Confirm the password"); return; } if ($password1 !== $password2) { $this->setFieldError("password2", "Confirm password is not match"); return; } $user = new Auth\User(); try { $new_user_id = $user->create($username, $password1); } catch (\Exception $e) { $this->setFieldError("username", $e->getMessage()); return; } $user->authorize($username, $password1); $this->message = sprintf("Hello, %s! Thank you for registration.", $username); $this->setResponse("redirect", "callback.php"); $this->status = "ok"; } } $ajaxRequest = new AuthorizationAjaxRequest($_REQUEST); if (\Auth\User::isAuthorized() != false) { header('Location: ../pages/add_product.php'); } else { $ajaxRequest->showResponse(); }