My query is the following, I need to direct to the same page that is created in php with html code, and within it I have a validation form via post, when I send the post to the same page that is index, I validate the fields with php , so if there is an error, I make a header location to the same page where I sent via get an ?id=error, but when the page is reloaded, it therefore remains at the beginning and I need it to go down to the id where the form is. how can I do it.
<?php
if(empty($_POST['usuario']))
{
header("Location:index.php?id=contacto&num=1");
?>
?>
codigo principal.....
<!-- formulario de contacto 60 lineas mas abajo -->
<div id="contacto">
<form method="POST">
<?php
if(num=="1")
{
//muestro mensaje de error
}
?>
<input name"usuario">
<input type="submit">
Well that's the idea, thank you very much in advance.
Use anchors next to your variables, add at the end of the #contact link (
id
of the div that contains the form):Solution
Ref: http://www.forosdelweb.com/f4/anclaje-variable-851568/
good friend you can use the following code to show the notice on the page when the request is sent by the form like this:
the other simpler would be like this: