form-select 不发送数据
form-select not sending data
我看不出某一特定 html 字段未发送数据的原因。
我的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>
虽然这被缩短了,但所有其他输入字段都在工作并包含在同一个 div class="row my-4 justify-content-md-center"
在我的 php 中,我尝试检查:
var_dump($_POST);die;
我可以看到除了选项之外的所有其他变量都在那里
还有一件事情。在发送信息之前我有一些验证:
$('#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 );
});
所以信息在发布之前就在那里,但由于某种原因它没有被识别为表单的一部分
编辑:我知道我可以使用 jquery 检索信息并通过创建一个新字段发送它,但我试图在这里理解我的 html 错误。
您没有给<select>
元素一个name="talla"
属性,因此它不会被发送到PHP代码。只有具有 name=
属性的字段 才能将数据发送到 PHP Code.
我看不出某一特定 html 字段未发送数据的原因。
我的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>
虽然这被缩短了,但所有其他输入字段都在工作并包含在同一个 div class="row my-4 justify-content-md-center"
在我的 php 中,我尝试检查:
var_dump($_POST);die;
我可以看到除了选项之外的所有其他变量都在那里 还有一件事情。在发送信息之前我有一些验证:
$('#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 );
});
所以信息在发布之前就在那里,但由于某种原因它没有被识别为表单的一部分
编辑:我知道我可以使用 jquery 检索信息并通过创建一个新字段发送它,但我试图在这里理解我的 html 错误。
您没有给<select>
元素一个name="talla"
属性,因此它不会被发送到PHP代码。只有具有 name=
属性的字段 才能将数据发送到 PHP Code.