I have a functions file where I handle POST and GETS letting the user perform either a post or a get. It's more like an API call.
Should I be doing it like this or would using $_REQUEST handle both a POST and a GET?
if ($_SERVER['REQUEST_METHOD'] === "GET") {
$function = $_GET['f'];
$user_id = $_GET['user_id'];
}
elseif ($_SERVER['REQUEST_METHOD'] === "POST") {
$function = $_POST['f'];
$user_id = $_POST['user_id'];
}
$res = new stdClass();
if (isset($function)) {
switch ($function) {
....
}
}