How do I change the contents of the screen using php

0

I have a system that has two possibilities of use for the user:

1.manual

2.automatic

I wanted the user to be able to choose between these two versions in the input type='radio' style. So just updating the page with the content that the customer chose (manual or automatic)

<body id="body">
    <div id="DivTopo">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <?php
                    include "TopoLogado.php";
                    ?>
                </div>
                <div> 
     <form action="Atividade.php">
    <INPUT TYPE="RADIO" NAME="OPCAO" VALUE="1">Kanban Automático
    <INPUT TYPE="RADIO" NAME="OPCAO" VALUE="2">Kanban Manual
    <input type="submit" value="atualizar">
    </form> 

                </div>
            </div>
        </div>

    </div>
    <div id="DivCentral"><br>
        <h1 class="Titulo">Tarefas de <?php echo $tblDetalhes['nome_ATIVIDADE'] ?></h1>

        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">


                    <?php 
                    if($_POST["OPCAO"]==1 ){

                    include 'KANBAN1.php';

                    } else if ($_POST["OPCAO"]==2){
                         include 'KANBAN2.php';
                    }
                    ?>

                    <div id="DivRodape">
                        <?php include "Rodape.php"; ?>  
                    </div>
                </div>
            </div>
        </div>
    </div>
  <script>
 <?php
 include "./JavaScript/Modal.js";
 ?>
    </script>
</body>

I thought about doing this too:

<div class="pre-spoiler">

<input id="xs" value="Leia Mais" style="margin-left: 50px; padding: 0px; width: 80px; " onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';this.innerText = ''; this.value = 'Ocultar'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.value = 'Leia Mais';}" type="button"> </div>

<div>

<div class="spoiler" style="display: none;">

<?php include 'KANBAN1' ?>

</div>

</div>

But the first one works, but the second does not (the same content of the first one appears)

    
asked by anonymous 10.12.2017 / 17:13

1 answer

0

If I understand what you want is that after the person chooses an option this option will be saved, is this?

And also have what @Paulo said, change the form to:

 <form action="" method="post">

action="" will refresh the current page so you do not have to enter the URL

If so, you can use cookies, you should keep your code:

<?php
if (!empty($_POST["OPCAO"])) {
     if ($_POST["OPCAO"] == 1 || $_POST["OPCAO"] == 2) {
        //Atualiza o valor quando o usuário solicitar (o cookie expira em um ano)
        setcookie('temakaban', $_POST["OPCAO"], time() + 31536000, '/');
        $_COOKIE['temakaban'] = $_POST["OPCAO"];
     }
}
?>
<html>

....

<body id="body">
    <div id="DivTopo">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <?php
                    include "TopoLogado.php";
                    ?>
                </div>
                <div> 
    <form action="" method="post">
    <INPUT TYPE="RADIO" NAME="OPCAO" VALUE="1">Kanban Automático
    <INPUT TYPE="RADIO" NAME="OPCAO" VALUE="2">Kanban Manual
    <input type="submit" value="atualizar">
    </form> 

                </div>
            </div>
        </div>

    </div>
    <div id="DivCentral"><br>
        <h1 class="Titulo">Tarefas de <?php echo $tblDetalhes['nome_ATIVIDADE'] ?></h1>

        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">

                    <?php
                    //Por padrão usará KANBAN1, acaso o usuário não tenha escolhido
                    if(empty($_COOKIE["temakaban"]) || $_COOKIE["temakaban"] == 1){
                         include 'KANBAN1.php';
                    } else if ($_COOKIE["temakaban"]==2){
                         include 'KANBAN2.php';
                    }
                    ?>

                    <div id="DivRodape">
                        <?php include "Rodape.php"; ?>  
                    </div>
                </div>
            </div>
        </div>
    </div>
  <script>
 <?php
 include "./JavaScript/Modal.js";
 ?>
    </script>
</body>
    
10.12.2017 / 18:06