2
I’ve got two little problems I’m bumping my head on, let’s go to the first one:
1- I have the code below just after my Submit to check that the data has all been filled in:
<?php
$data_coleta = $_POST["data_coleta"];
$hora_coleta = $_POST["hora_coleta"];
$unidade = $_POST["unidade"];
$observacao = $_POST["observacao"];
$solicitante = $_POST["solicitante"];
$coletadora = $_POST["coletadora"];
$erro = 0;
// Verifica se os campos não estão em branco
if (empty($data_coleta))
{echo "Favor inserir a Data da Coleta.<br>"; $erro=1;}
if (empty($hora_coleta))
{echo "Favor inserir a Hora da Coleta.<br>"; $erro=1;}
if (empty($unidade))
{echo "Favor inserir a Unidade.<br>"; $erro=1;}
if (empty($observacao))
{echo "Favor inserir a Observação.<br>"; $erro=1;}
if (empty($solicitante))
{echo "Favor inserir o Solicitante.<br>"; $erro=1;}
if (empty($coletadora))
{echo "Favor inserir a Coletadora.<br>"; $erro=1;}
//Verifica se não houve erro
if($erro==0)
{echo "<center>Todos os dados foram inseridos corretamente!</center>";
include 'insere.php';
}
?>
The problem is that right away PHP is returning me an error saying that the variables have no value defined, this is because it has not yet been given Submit in the form to define the values (which is what is inserted by the user), I imagine I then need to do an if to only do this value check after being given Ubmit, how to do?
2- I think there’s something in the Bootstrap JS that I’m using that asks that always when refreshing the page should return to the top, so I can’t direct the form action to the div that I need, JS the button to go to the top below:
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1200);
});
});
</script>
<a href="#" id="toTop" style="display: block;"><span id="toTopHover" style="opacity: 1;"></span></a>
Tips?
Makes a
if isset
in his$_POST
before making the verification– Leonardo Pessoa
Get this man an Oscar! It was very simple, but as I’m learning everything by myself I don’t know some basic functions and what they do, thank you very much! Only need to resolve the issue of returning to the Register DIV.
– Fernando Gross
Do one last test, in the form action put . php##support and in <a name="#support"></a>
– user60252
The page is not found, I will send open the result of the registration (it is a service protocol) in a popup, is the way, is even more beautiful if I can configure the Magnific Popup.
– Fernando Gross
see in the answer some considerations regarding anchors.
– user60252