Alternatives to the POST page request method

1

I'm developing a web application for my work. It consists of a dashboard that will present company information to the managers. In this context, I'm trying to optimize the page by searching for the appropriate content according to the mode I'm looking for. Thus, I made a menu containing the three types of teaching that the company works: college, undergraduate and graduate. I was making the menu buttons like forms that would redirect to a page that would have a function that verifies the mode sent via POST. It's functional, yet whenever I try to go to another page it accuses form data can get lost and becomes an uncomfortable thing. In this way, I would like tips and suggestions on how to re-do to get to the end result I want without having this form message.

Function that returns page

function get_page_modalidade($modalidade = "home"){
    if($modalidade == COLEGIO){
        return print "include './parts/menu-detalhe.php'" ;
    } elseif ($modalidade == "home") {
        return print "include './parts/menu-detalhe.php'" ;
    } elseif ($modalidade == GRAD) {
        return print "include './parts/menu-detalhe.php'" ;
    } elseif ($modalidade == POS) {
        return print "include './parts/menu-detalhe.php'" ;
    } else{
        return "outro";
    }
}

Function call

<?php  get_page_modalidade($_POST['modalidade']);?>

Menu button

<li>
    <form action="index.php" method="post">
        <input type="hidden" name="modalidade" value="home">
        <input type="submit" name="home" value="Dashboard" class="btn-block btn btn-focus btn-menu">
    </form>

    
asked by anonymous 17.02.2017 / 15:30

1 answer

0

Good afternoon Rafael, the alternative I recommend to the HTTP POST method is HTTP GET, responding most directly to the title of your question.

As I understand it, your difficulty is not to manage the modules but rather to avoid the browser warning about revisiting a URL in HTTP POST method, which is when whenever I try to go to another page it accuses form data can get lost and becomes an annoying thing. As you explained.

I will use a similar example: I have an e-commerce site and have a form POST method whose action is index.php/busca , this action expects some form data, processes them and after finding the products, makes a redirect GET to other URL, so I can avoid this same situation that you describe, because if you click on the Back button of the browser it will not go back to the search action. p>

I hope I have helped, ah a hint, I replaced your block if..elseif of the mode with a switch since the conditions are all the same ;-) The code gets cleaner.

    
17.02.2017 / 19:44