<script>
history.go(-2)
</script>
To return two pages back and in this page lists my items in the table, but when it comes back it seems that the page does not update so my new table item does not appear, so it appears I need to refresh the page, to send the form update dps back the pages?
My whole code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link type="text/javascript" href="jquery.js">
<link type="text/javascript" href="post.js">
<link type="text/javascript" href="jquery-form.js">
<body >
<form action="" method="post" enctype="multipart/form-data">
<fieldset>
<?php
ini_set('default_charset','UTF-8');
if(isset($_POST['send'])){
$produtos = $_POST['produtos'];
$id_venda = $_POST['id_venda'];
include ('banco.php');
mysql_query("INSERT INTO pedido(id, produtos, id_venda )
values(
NULL,
'{$produtos}',
'{$id_venda}'
)
");
echo '<script>history.go(-2) </script>';
}
?>
<legend style="color: #ffffff" class="btn btn-inverse">Cadastro </legend>
<?php
ini_set('default_charset','UTF-8');
mysql_connect('127.0.0.1','root','');
mysql_select_db('mecanica');
$query='Select * from produtos';
?>
<label for="produtos" style="color: #000"><strong>Produto : </strong></label>
<select name="produtos" style="width: 400px">
<?php
//execução da query
$resultado=mysql_query($query);
while($linha=mysql_fetch_array($resultado))
{
echo '<option value="' . $linha['id_produto'] . '">' . $linha['produtos'] . '</option>';
}
echo '</select>';
?>
</select><br><br>
<?php $id_ven = $_GET["id_venda"]; ?>
<script type="text/javascript">
function mostra() {
if (document.getElementById('ocultar').style.display == 'block'){
document.getElementById('ocultar').style.display = 'none';
}else {document.getElementById('ocultar').style.display = 'block'}
}
</script>
<div id="ocultar" style="visibility: hidden" >
<?php
ini_set('default_charset','UTF-8');
mysql_connect('127.0.0.1','root','');
mysql_select_db('mecanica');
$query='Select * from pedido';
?>
<label for="id_venda" style="color: #000"><strong>ID VENDA : </strong></label>
<select name="id_venda" style="width: 75px">
<?php
$resultado=mysql_query($query);
while($linha=mysql_fetch_array($resultado))
{
}
echo '<option >' . $_GET['id_venda'] . '</option>';
echo '</select>';
?>
</select><br><br>
</div>
<input type="submit" class="btn btn-inverse" value="Enviar" name="send">
<a href="listadevendas.php" class="btn btn-inverse">Cancelar</a>
</fieldset>
</form>
</body>
</html>