I'm putting a command inside a script so that when the user presses the "submit" button, the given data is written to the database and soon after that a page redirect happens:
<script type="text/javascript">
function cadAlterar (){
<?php
$idComp = (@$_POST['id']);
$insert = mysql_query("INSERT INTO alterar(idComp) VALUES ('$idComp')");
?>
location.href="altCompras.php";
}
</script>
Save the data right in the Database, but in return there is no redirection.