Eae galera to aqui faz moh tempão tentando resolver um problema em um sisteminha, o problema esta no cadastro, estou passando uma variavel por GET, assim que eu cadastro e o POST é ativado a variavel GET limpa, gostaria que ela não limpasse, e meu POST está sendo enviado para a própria página, ta ai o codigo:
Código:
<?php include ("verifica.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Freta Brasil</title> <?php ob_start(); include("include/css.php"); include("include/script.php"); header("Content-Type: text/html; charset=ISO-8859-1", true); ?> </head> <body> <?php include("include/topo.php"); include("include/menu.php"); ?> <div id="fundo_paginas"> <div id="geral_paginas"> <div id="conteudo"> <form id="form1" name="form1" method="post" action="addcidade.php"> <table style="margin-top:80px;" width="100%" border="0" align="center"> <tr> <td><div align="center"> <h1>Adicione uma Cidade para o Estado</h1> </div></td> </tr> </table> <table width="100%" border="0" align="center"> <tr> <td> <?php include("include/conexao.php"); $codigo = $_GET['id']; if($_SERVER['REQUEST_METHOD']=="POST") { $nome_cidade = mysql_real_escape_string($_POST['nome_cidade']); $cod_est = mysql_real_escape_string($_POST['cod_est']); if(empty($nome_cidade)){ $retorno = '<div align="center" id="falha">Digite o nome da cidade!</div>'; } $selec = "select * from cidade where nome ='$nome_cidade'"; $registros = mysql_query($selec); if(mysql_num_rows($registros)) { echo '<div align="center" id="falha">Cidade já cadastrada!</div>'; echo "<META HTTP-EQUIV=REFRESH CONTENT=1; URL=addcidade.php>"; $codigo = $cod_est; }else{ if(empty($retorno)){ $sql = "INSERT INTO cidade (nome, cod_estado) VALUES ('$nome_cidade', $cod_est);"; mysql_query($sql,$con); echo '<div align="center" id="sucesso">Cidade cadastrada com sucesso!</div>'; echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=addcidade.php'>"; $codigo = $cod_est; }else{ echo "$retorno"; } } } ?> </td> </tr> </table> <table width="250" border="0" align="center"> <tr> <td width="51">Cidade:</td> <td width="158"><input type="text" name="nome_cidade" id="nome_cidade" /></td> <td width="27"><input type="hidden" name="cod_est" id="cod_est" value="<?php echo "$codigo"; ?>" /></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="cadastrar" id="cadastrar" value="Cadastrar" /> </label></td> <td> </td> </tr> </table> </form> </div> <!-- conteudo --> </div><!-- geral_paginas --> </div><!-- fundo_paginas --> <?php include("include/rodape.php"); ?> </body> </html>
Comment