How will I pass this id with the $ _POST variable to PHP

0

I do this in my "form" to list in a "Combobox" the places that are registered in the database:

<select class="form-control input-sm" name="cbEditarVagas" id="cbEditarVagas">
<option disabled selected>Selecione</option>
<?php
  mysqli_select_db($db, $connect);
  //Listar os grupos na listbox
  $result = mysqli_query($connect, "SELECT id, titulo_vaga FROM tabela_cadastro_vagas ORDER BY titulo_vaga");
  while ($row = mysqli_fetch_array($result)) {
  $titulo_vaga = str_replace("?","",$row{"titulo_vaga"});
  echo "<option value='".$row{'id'}."'>$titulo_vaga</option>";
  }
  ?>
  </select>

I use the $ _POST variable to get this id on the PHP side

$id = $_POST['cbEditarVagas'];

I wonder if they are doing this correctly, and what would be the best way?

    
asked by anonymous 26.06.2018 / 18:39

1 answer

0

I recommend using some filter or sanitization when receiving user values on your backend. Never trust user input. See about filter_var()

link

    
26.06.2018 / 19:43