form-select not sending data
I dont see the reason why one particular html field is not sending data.
My html:
<form id="login_registro_form" role="form" method="post" action="./controllers/register.php">
<div class="row my-4 justify-content-md-center">
<label class="col-lg-3" for="regName">NOMBRE</label>
<input type="text" class="form-control" id="regName" placeholder="SEGÚN APARECE EN EL DNI/PASAPORTE" name="regName">
<div class="invalid-feedback ">El nombre es un campo obligatorio </div>
</div>
<div class="row my-4 justify-content-md-center">
<label class="col-lg-3" for="reg_birthday">CONFIRMA TU TALLA</label>
<select class="form-select" id="talla" nombre="talla" aria-label="Default select example">
<option value="xs">XS</option>
<option value="s">S</option>
<option value="m" selected>M</option>
<option value="L">L</option>
<option value="xl">XL</option>
<option value="xxl">XXL</option>
</select>
</div>
<div class="login_cb justify-content-md-center">
<label for="reg_allergies">ALERGIAS, INTOLERANCIAS O DIETAS ESPECIALES</label>
<input type="checkbox" class="form-check-input " id="reg_allergies" name="allergies" >
</div>
<button id="register_button" type="submit" class="btn btn-primary" >GUARDAR</button>
</form>
While this is shortened all the other imput fields are working and enclosed within the same div class="row my-4 justify-content-md-center"
In my php i tried checking with:
var_dump($_POST);die;
I am able to see there that ALL of the other variables are there except the options And one more thing. I have some validations before i send the information:
$('#login_registro_form').submit(function(e) {
//My validations for the rest of the form
console.log($('#talla').val()); //THIS IS ACTUALLY SHOWING THE INFORMATION
return (errores.length <= 0 );
});
So the information IS there just before posting it, but for some reason it is not being recognised as part of the form
Edit: I know i can retrieve the information using jquery and send it it by creating a new field, but im trying to understand my html mistake here.
Solution 1:
You have not given the <select>
element a name="talla"
attribute, Therefore it is not sent to the PHP code. Only fields with a name=
attribute can send data to PHP Code.