I have problems with this form to pass the given by PHP medium, but I can’t get the error

Asked

Viewed 36 times

3

I have this form inside a modal of bootstrap;

<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 I’m simply trying to show the value of one of the fields but the Undefined variable error. And this is the php code to show the form values

<?php 
 $precioNuevo = $_GET['update_venta'];
 echo $precioNuevo;
?>

1 answer

3


Basically a submit button is missing inside the form, if the button is outside the form or if you are only using 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 caution to observe is to use the correct method (for example GET for $_GET[] and POST for $_POST[].

Browser other questions tagged

You are not signed in. Login or sign up in order to post.