I have problems with this form to pass the data through PHP, but I can not get the error

3

I have this form within a bootstrap modal;

<form action="form_handler.php" method="get" name="precioUpdate">
  <div class="col-xs-6">
    <label for="venbras_actual_venta" class="col-xs-12 form-control-label">Precio actual de venta:</label>
    <label for="venbras_actual_venta" class="col-xs-12 form-control-label" id="venbras_modal_venta"></label>
  </div>
  <div class="form-group col-xs-6">
    <label for="venbras_modal_update_venta" class="form-control-label">Nuevo precio de venta:</label>
    <input type="text" class="form-control" name="update_venta" value="000" id="update_venta" />
  </div>
  <div class="col-xs-6">
    <label for="venbras_actual_compra" class="col-xs-12 form-control-label">Precio actual de compra:</label>
    <label for="venbras_actual_compra" class="col-xs-12 form-control-label" id="venbras_modal_compra"></label>
  </div>
  <div class="form-group col-xs-6">
    <label for="recipient-name" class="form-control-label">Nuevo precio de compra:</label>
    <input type="text" class="form-control" id="recipient-name">
  </div>
</form>

And this is simply trying to show the value of one of the fields but the variable Undefined error. And this is the php code to display the values of the form

<?php 
 $precioNuevo = $_GET['update_venta'];
 echo $precioNuevo;
?>
    
asked by anonymous 31.12.2016 / 16:50

1 answer

3

Basically a submit button is missing inside the form, if the button is outside the form or if it is using only a link, the data is not sent:

<form action="form_handler.php" method="get" name="precioUpdate">
  <div class="col-xs-6">
    <label for="venbras_actual_venta" class="col-xs-12 form-control-label">Precio actual de venta:</label>
    <label for="venbras_actual_venta" class="col-xs-12 form-control-label" id="venbras_modal_venta"></label>
  </div>
  <div class="form-group col-xs-6">
    <label for="venbras_modal_update_venta" class="form-control-label">Nuevo precio de venta:</label>
    <input type="text" class="form-control" name="update_venta" value="000" id="update_venta" />
  </div>
  <div class="col-xs-6">
    <label for="venbras_actual_compra" class="col-xs-12 form-control-label">Precio actual de compra:</label>
    <label for="venbras_actual_compra" class="col-xs-12 form-control-label" id="venbras_modal_compra"></label>
  </div>
  <div class="form-group col-xs-6">
    <label for="recipient-name" class="form-control-label">Nuevo precio de compra:</label>
    <input type="text" class="form-control" id="recipient-name">
  </div>
  <div class="form-group col-xs-6">
    <input type="submit" value="Enviar">
  <div>
</form>

If you are going to use Ajax, the right thing to do is to use the correct method (for example GET to $_GET[] and POST to $_POST[] .     

31.12.2016 / 17:10