I have some validation fields like this :
if (empty($_POST['finalidade_imob']) || $finalidade_imob == "Escolha 1" ||
!in_array($_POST['finalidade_imob'], $fi_options)) {
$finalidade_imob = "Escolha 1";
$error++;
} else {
$finalidade_imob = $_POST['finalidade_imob'];
}
//on the end
if ($error !== 0) {
return false;
}
But the location of my form is on bottom of my page, so when return false
is called the page is reloaded on the top.
If i put this:
if ($error !== 0) {
header('location:perfil.php#content_cadastro_completo');
return false;
}
This page is reloaded for exactly to the place i need, but return false
dont work... I know why return
dont work, i put that for explain what i need...
So what i need do to goal this target?
Sorry my bad english...
Edit Without js... Only PHP.
My question no clear for this solution, but in my all context this work.
The solution that I found is put placeholder in my action
.
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>#content_cadastro_completo"
and
if($error !== 0)
{ return false;//no need header() to go to the placeholder...
}