I am creating a PHP page that takes input via request parameters. My design currently routes all actions through one action.php
which contains a function like this:
function get_param($name, $default_value=null) {
$value = @$_GET[$name];
if ($value == null) {
$value = @$_POST[$name];
if ($value == null) {
$value = $default_value;
}
}
return $value;
}
Then there is some other code that will look at the parameters on the request to tell what kind of action it is, each action can take other parameters. The action code would look something like this:
$action = get_param("action");
switch ($action) {
case "login":
login(get_param("user_name"), get_param("password");
break;
case "create_todo":
create_todo(get_param("todo"));
break;
case "get_todo":
get_todo();
break;
// Various other cases
}
Now let's assume that this PHP page is accessible through the internet as a general service for any website to use. As you can see, the actions contains things like login, and many other actions.
Also, let's assume that I properly validate each request (in terms of permissions as well as input length, etc).
Are there any risks in allowing the user the ability to choose if the request is a GET or a POST, and the action.php will work either way?
Should certain actions should be forced to POST (such as login, or create_todo) and others to GET (such as get_todo)?