I have a problem related to HTML, Jquery and PHP, I will try to get as much information as possible. I have a PHP page that has to go back and forth with the variables and it's kind of a step by step, where each step sends its data to the next to filter the tables in the MySQL database. My problem is that the variable goes but not back. So I'm including in the project AJAX requests, where as I click the button I send to the same page via POST in the JQuery values. The problem is that the variable is not taking this value. Would I have to set this variable after the click on the button, or pass this value in another way? I'll send the codes.
console.log($("#prox1"));
$("#prox1").click(function(event) {
console.log("Ok");
console.log($("#curso").val());
console.log($("#turno").val());
console.log($("input[name='tipoLab']:checked").val());
var dados1 = {curso: $("#curso").val(), turno: $("#turno").val(), tipoLab: $("input[name='tipoLab']:checked").val()};
$.post('../processamento/index.php', dados1, function() {
console.log("Fui e voltei");
});
});
<div class="ls-steps-content" id="step1">
<?php $sql ="SELECT cursos from cursos order by cursos asc";
$resultado = conecta( $maquina , $usuario, $senha, $banco, $sql );?>
<div class="ls-custom-select selectEtapa1">
<select id="curso" name="curso" class="ls-select">
<option selected="selected" disabled="disabled"> Cursos </option>
<?php while ($row = mysql_fetch_assoc($resultado)) {
$curso = $row["cursos"];
?>
<option value="<?=$curso?>"><?=$curso?></option>
<?php } ?>
</select>
</div>
<div class="ls-custom-select selectEtapa1">
<select id="turno" name="turno" class="ls-select">
<option selected="selected" disabled="disabled"> Turno </option>
<option value="Manha"> Manhã </option>
<option value="noite"> Noite </option>
</select>
</div>
<fieldset>
<!-- Exemplo com Radio button -->
<div class="ls-label col-md-5">
<p>Escolha uma das plataformas:</p>
<label class="ls-label-text">
<input type="radio" name="tipoLab" value="labinfo">
Laboratório de informática
</label>
<label class="ls-label-text">
<input type="radio" name="tipoLab" value="labEng">
Laboratorio de Engenharia
</label>
<label class="ls-label-text">
<input type="radio" name="tipoLab" value="labSau">
Laboratório de Saúde
</label>
</div>
</fieldset>
<div class="ls-actions-btn">
<form method="post" action="index.php">
<input type="hidden" name="curso">
<button type="submit" id="prox1" href="#" class="ls-btn-primary ls-float-right" data-action="next">Próximo</button>
</form>
</div>
</div>
<div class="ls-steps-content" id="step2">
<?php $_POST["curso"] ?>
<div class="ls-actions-btn">
<a href="#" class="ls-btn" data-action="prev">Anterior</a>
<a href="#" class="ls-btn-primary ls-float-right" data-action="next">Próximo</a>
</div>
</div>
If someone has another way of helping me, it can be too, I just need to keep going back and forth with those variables when the user wants.
Thank you in advance