The data is not saving

Asked

Viewed 46 times

1

I created a project that contains the admin that selects the hours to be available to the customer and has the contact page, when I go first on admin and select the time and click update (button that I created) it goes to contact page and appears the hours I selected... now when I click first on the home and then go back to contact page the hours I selected are no longer there... my question is, must be why I am locally and why it happens?

I’m afraid I host the site and the problem still continues, because it is not appearing the hours I selected soon after I have given a "browse" on my site....

PHP code and the page that receives the data:

      <div class="container">
        <div class="row">
            <div class="campo-externo">
                <div class="caixa-registrado col-lg-12">
                    <p>Marca uma visita agora!</p>

                    <form>
                        <div class="row">
                            <div class="col-lg-6">
                                <input class="detalhe-campo-velho" type="text" placeholder="Nome">
                            </div>


                            <div class="col-lg-6">
                                <input class="detalhe-campo-velho" type="number" placeholder="Codigo de segurança">
                            </div>

                        </div>
                        <hr />

                        <form>
                            <div class="campo-agenda-novo">
                                <p class="texto-centro">Agenda disponível</p>

                                <div class="row">
                                    <div class="col-lg-12 texto-centro">

                                <?php 

                                        if(isset($_POST["hora"])) {


                                            for($i = 0; $i < count($_POST["hora"]); $i++) {


                                    echo " ".$_POST["hora"] [$i]." <input type='radio'/> </br>";

                                    }                                                          
                                        }
                                ?>


                                    </div>
                                </div>
                                <hr />
                            </div>
                        </form>

                        <div class="texto-centro">
                            <button class="botao-confir margin-top20">Confirmar</button>
                        </div>
                    </form>

                </div>
            </div>

        </div>
        <hr class="linha-cinza" />
    </div>

Admin page :

<form method="post" action="agendamento.php">
    <div class="row texto-centro">
        <div class="col-lg-12 texto-centro">
            <span>10:00</span>
            <input type="checkbox"  id="blankRadio1" value="10:00" name="hora[]" aria-label="..." ng-model="um">
            <br />
            <span>10:30</span>
            <input type="checkbox"  id="blankRadio1" value="10:30"  name="hora[]" aria-label="..." ng-model="dois">
            <br />
            <span>11:00</span>
            <input type="checkbox"  id="blankRadio1" value="11:00" name="hora[]" aria-label="..." ng-model="tres">
            <br />
            <span>11:30</span>
            <input type="checkbox"  id="blankRadio1" value="11:30" name="hora[]" aria-label="..." ng-model="quatro">
            <br />
            <span>13:00</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="13:00" aria-label="..." ng-model="cinco">
            <br />
            <span>13:30</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="13:30" aria-label="..." ng-model="seis">
            <br />
            <span>14:00</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="14:00" aria-label="..." ng-model="sete">
            <br />
            <span>14:30</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="14:30" aria-label="..." ng-model="oito">
            <br />
            <span>15:00</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="15:00" aria-label="..." ng-model="dez">
            <br />
            <span>15:30</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="15:30" aria-label="..." ng-model="onze">
            <br />
            <span>16:00</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="16:00" aria-label="..." ng-model="doze">
            <br />
            <span>16:30</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="16:30" aria-label="..." ng-model="treze">
            <br />
            <span>17:00</span>
            <input type="checkbox" name="hora[]" id="blankRadio1" value="17:00" aria-label="..." ng-model="quatorze">
            <br />
        </div>
    </div>

    <div class="row texto-centro margin-top20">
        <button ng-click="atualizar()" value="descobrir">Atualizar</button>

    </div>
</form>

Someone could explain me how it works... I know that to do the sending of email through php it requires that the site is hosted, already this method I did not know if the site needs to be hosted.

1 answer

2

Your receiving page is using $_POST to display the selected hours. The $_POST variable only exists when you send it from a form (it’s the values entered in the input fields). If you go from the Home->Page that receives data, the $_POST variable will not be set, so you will not have anything to display.

  • Ah tendi... and how could solve this problem... I needed to save these variables because the user will want to browse the site and then come back to mark the time...

  • 1

    In the case of most recommended is that you save THE VALUES OF THE VARIABLES in a database. Then, when you display them, just search the database. To know how to do this, just search over CRUD (Create, Read, Update, Delete - actions to do in a database).

  • But when I save the variable data in the database I will be able to manipulate which data I want to show on the other screen?

  • 1

    Any data saved in the bank can be manipulated. That’s why I recommended that you read about CRUD.

  • I get it... thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.