1
I am developing a web application for my work. It consists of a Dashboard that will present company information to managers. In this context, I am trying to optimize the page by searching for the appropriate content according to the modality I seek. Thus, I made a menu containing the three modes of teaching that the company works: college, undergraduate and graduate. I was making the menu buttons as forms that would redirect to a page that would have a function that checks the mode sent via POST. It is functional, however whenever I try to go to another page it accuses that form data may get lost and becomes an uncomfortable thing. This way, I would like tips and suggestions on how to re/do to reach the final result I crave 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>
Enter the code you have....
– MagicHat
Have some special reason to be doing by POST?
– Randrade
@Randrade Yes. I use the link to identify the name of the page. When I use GET it displays parameters that may give error.
– Rafael Pessoa
@Magichat I just updated with the main codes.
– Rafael Pessoa
I’m beginning to understand, speaks a business, after you do the checking what happens, which continuation of the code ?
– MagicHat
Also I did not understand why to use post for a simple link, what will happen if the user adds the page in the favorites? favourites do not save data uploaded via post.
– Washington da costa
@Magichat the intention is to do something similar to what Wordpress does with the get_template_part() function. I want that when I click on the menu link I do not have to redirect to a page for each item, but rather load the modules according to the request. In a common template, when I link with the <a> tag it redirects to a specific page. If I have 10 items on the menu, I’ll have to make 10 pages. The way I want to do it is to redirect to a single page and a function load the modules that each predefined mode has.
– Rafael Pessoa
@Washingtondacosta I wanted to fetch the content of the pages according to the mode of teaching. A button with the "school" mode will pass via POST to the page in PHP that analyzes the modality and searches the correct module, without having to create a page for each module.
– Rafael Pessoa