//Switch through the post of redirectType switch (strtolower($_POST['redirectType'])) { //If the redirectType is login. case "login": if (!empty($user)) { new Customer($user); header("Location: http://" . $_SERVER['SERVER_NAME'] . "/faseovergang/index.php"); } else { echo "Invalid credentials"; } break; //If the redirectType is register. //If the redirectType is register. case "register": if (empty($user)) { $db->addCustomer($_POST['username'], $_POST['password']); header("Location: http://" . $_SERVER['SERVER_NAME'] . "/faseovergang/index.php?page=login"); } else { echo "There is already such user."; } break; //If there is a different variable given. This will prevent errors. //If there is a different variable given. This will prevent errors. default: echo "This page hasn't been found"; break; } //Display the details of the customer } else { header("Location: http://" . $_SERVER['SERVER_NAME'] . "/faseovergang/index.php"); }