<?php include "lib/init.php"; //general php implements 3 operations login, logout, register $user = get_user(); //get user and authentication check $action = $_GET["action"]; $method = $_SERVER["REQUEST_METHOD"]; switch ($action) { case "list": contacts::listContacts(); break; case "add": if ($method === "GET") { contacts::displayAddContactForm(); } elseif ($method === "POST") { contacts::handleAddContact(); } break; case "delete": $id = $_GET["id"]; delete_contact($id); header("Location: /contacts.php?action=list"); break; case "edit": $id = $_GET["id"]; if ($method === "GET") { contacts::displayEditContactForm($id); } elseif ($method === "POST") { contacts::handleEditContact($id); }