Formuj dane do klasy PHP

function login(Array $data){
    // Whatever your code does
}

if($_POST['action'] == "login") {
    login($_POST);
}
Shy Sandpiper