$_POST["username"],"pwd"=>$_POST["pwd"]]; try { require_once "dbh.inc.php"; require_once "register_model.inc.php"; require_once "register_view.inc.php"; require_once "register_contr.inc.php"; // Error handlers $errors = []; if (isEmpty($inputs)) { $errors = ["null_field" => "Form contains blank characters."]; } if (username_taken($pdo, $inputs["username"])) { $errors = ["username_taken" => "Username alredy taken"]; } require_once "config_session.inc.php"; if ($errors) { $_SESSION["errors"] = $errors; // Send back form $entered_data = [ "username" => $inputs["username"] ]; $_SESSION["entered_register_data"] = $entered_data; header("Location: ../chat.php"); $inputs = null; die(); } user_register($pdo, $inputs["username"], $inputs["pwd"]); header("Location: ../chat.php"); $inputs = null; die(); } catch (PDOException $e) { echo "An error has ocurred: " . $e->getMessage(); exit(); } } else { echo "Wrong request type, please check your request."; exit(); }