I already have my form and my validations done, what I really want is that when you enter information in the (input) text boxes of the form and when you leave a text box ( input) empty or incorrectly validated, do not delete the fields that are correct at the time the form is updated to display the error message
Veran I have my formulario.php
<div class="form-group">
<label>Nombre(s) del socio</label>
<input type="text" name="nom" class="form-control" placeholder="Ingrese nombre...">
</div>
<?php
if(isset($_SESSION['error1'])){
echo "<div class='alert alert-danger'>".$_SESSION['error1']."</div>";
}else{
echo "";
}
unset($_SESSION['error1']);
?>
<!-- /.form-group -->
<div class="form-group">
<label>Apellido Paterno</label>
<input type="text" name="paterno" class="form-control" placeholder="Ingrese apellido...">
</div>
<?php
if(isset($_SESSION['error2'])){
echo "<div class='alert alert-danger'>".$_SESSION['error2']."</div>";
}else{
echo "";
}
unset($_SESSION['error2']);
?>
<!-- /.form-group -->
<div class="form-group">
<label>Apellido Materno</label>
<input type="text" name="materno" class="form-control" placeholder="Ingrese apellido...">
</div>
<?php
if(isset($_SESSION['error3'])){
echo "<div class='alert alert-danger'>".$_SESSION['error3']."</div>";
}else{
echo "";
}
unset($_SESSION['error3']);
?>
<!-- /.form-group -->
and I have the file of my validaciones.php
<?php
session_start();
$nombre = $_POST["nom"];
$paterno = $_POST["paterno"];
$materno = $_POST["materno"];
$errores = array();
if($nombre == ""){
$errores[] = true;
$_SESSION["error1"] = "¡Campo vacío! Ingrese el dato solicitado.";
}
if($paterno == ""){
$errores[] = true;
$_SESSION["error2"] = "¡Campo vacío! Ingrese el dato solicitado.";
}
if($materno == ""){
$errores[] = true;
$_SESSION["error3"] = "¡Campo vacío! Ingrese el dato solicitado.";
}
if(count($errores)>0){
header("Location: form_add.php");
}else{
//aqui hago la consulta para agrgar los datos a la BD
$_SESSION['exito']="¡Registro éxitoso!";
header("Location: lista_socios.php");
}
?>