0
I have this problem and can not solve, the form is correct but when the user clicks the save button, the save.php file is triggered normally, but loses the contents of $_POST.... Help me!
index.php file
<!DOCTYPE html>
<html lang="pt" class="no-js">
<body>
<div>
<div>
<form action="salvar.php" method="post">
<div class="row">
<div class="form-group">
<label for="name">Id</label>
<input type="text" class="form-control" name="id" value="">
</div>
<div class="form-group">
<label for="name">Código</label>
<input type="text" class="form-control" name="codigo" value="">
</div>
<div class="form-group">
<label for="name">Descrição</label>
<input type="text" class="form-control" name="descricao" value="">
</div>
</div>
</form>
</div>
<div>
<button type="submit" onclick="salvar()">Salvar</button>
<button type="button" onclick="fechar()">Cancelar</button>
</div>
</div>
<script type="text/javascript">
function salvar() {
window.location.href = "salvar.php";
}
</script>
</body>
</html>
In the save.php file I read the $_post variable and the value is empty, as shown in the attached file.
php save file
<!DOCTYPE html>
<html lang="pt" class="no-js">
<body>
<?php
var_dump($_POST);
?>
</body>
</html>
Upshot:
C: wamp www save.php:5: array (size=0) Empty
I can’t fix it, and I’ve already missed the whole Sunday. I didn’t change the version of anything, no update. Good week everyone and thank you for taking your time.
You want to use Ajax for this?
– Sam