Pessoal fiz uma pagina em php com verificacao dos campos, só que quando não preenche o campo ele acusa o nome dos campos o erros e tem um link para volta, neste link deveria voltar a pagina anterior com as informacoes já preenchidas(java script:history.go(-1)), mais o campo volta em branco.
o java script:history.go(-1) ta na ultima parte do php.
Pergunta
SpoolmaN
Pessoal fiz uma pagina em php com verificacao dos campos, só que quando não preenche o campo ele acusa o nome dos campos o erros e tem um link para volta, neste link deveria voltar a pagina anterior com as informacoes já preenchidas(java script:history.go(-1)), mais o campo volta em branco.
o java script:history.go(-1) ta na ultima parte do php.
cadastro.php
<?php include "ver_sessao.php"; include "conecta.php"; $Nome = $_POST['Nome']; $Pessoa = $_POST['Pessoa']; $Valor_suporte = $_POST['Valor_suporte']; $Endereco = $_POST['Endereco']; $Data = $_POST['dia']."/".$_POST['mes']."/".$_POST['ano']; $Num_contrato = $_POST['Num_contrato']; $Email = $_POST['Email']; $Cidade = $_POST['Cidade']; $CEP = $_POST['CEP']; $Telefone1 = $_POST['Telefone1']; $Telefone2 = $_POST['Telefone2']; $Celular = $_POST['Celular']; $Complemento = $_POST['Complemento']; $CNPJ = $_POST['CNPJ']; $Bairro = $_POST['Bairro']; $Estado = $_POST['Estado']; $Situacao = $_POST['Situacao']; $Forma_pag = $_POST['Forma_pag']; $Valor = $_POST['Valor']; $Status_suporte = $_POST['Status_suporte']; $Instalador = $_POST['Instalador']; $Quant_comp = $_POST['Quant_comp']; $Registros = $_POST['Registros']; $Servicos = $_POST['Servicos']; $Obs = $_POST['Obs']; $usuario = $_SESSION["nome_usuario"]; $msgconfirma = "Cliente cadastrado com Sucesso!!"; if(isset($_POST['cadastrar'])) { $erros = 0; if($Num_contrato == '') { $erros++; $html_erros = $html_erros."<br>Digite o numero do contrato."; } if($Nome == '') { $erros++; $html_erros = $html_erros."<br>Digite o Nome / Razao Social."; } if($Cidade == '') { $erros++; $html_erros = $html_erros."<br>Digite a Cidade."; } if($Estado == '') { $erros++; $html_erros = $html_erros."<br>Digite o Estado."; } if($Endereco == '') { $erros++; $html_erros = $html_erros."<br>Digite o Endereco."; } if($Pessoa == '') { $erros++; $html_erros = $html_erros."<br>Selecione pessoa fisica ou juridica."; } if($Data == '') { $erros++; $html_erros = $html_erros."<br>Digite a Data de contratacao."; } if($CNPJ == '') { $erros++; $html_erros = $html_erros."<br>Digite o CNPJ."; } if($Email == '') { $erros++; $html_erros = $html_erros."<br>Digite o Email de contato."; } if($Cidade == '') { $erros++; $html_erros = $html_erros."<br>Digite a Cidade."; } if($Forma_pag == '') { $erros++; $html_erros = $html_erros."<br>Digite a Forma de Pagamento."; } if($Bairro == '') { $erros++; $html_erros = $html_erros."<br>Digite o Bairro."; } if($Situacao == '') { $erros++; $html_erros = $html_erros."<br>Selecione a Situacao do Contrato."; } if($CEP == '') { $erros++; $html_erros = $html_erros."<br>Digite o Cep."; } if($Telefone1 == '') { $erros++; $html_erros = $html_erros."<br>Digite o Telefone."; } if($Servicos == '') { $erros++; $html_erros = $html_erros."<br>Digite o Servico Contratado."; } if($Valor == '') { $erros++; $html_erros = $html_erros."<br>Digite o Valor."; } if($Status_suporte == '') { $erros++; $html_erros = $html_erros."<br>Selecione o Status do Suporte."; } if($Instalador == '') { $erros++; $html_erros = $html_erros."<br>Selecione o nome do Instalador."; } if($erros == 0) { $sql = mysql_query("INSERT INTO banco_clientes(Num_contrato, Nome, CNPJ, Data, Valor, Forma_pag, Status_suporte, Obs, Instalador, Servicos, Quant_comp, Registros, Cidade, Endereco, CEP, Email, Estado, Complemento, Bairro, Situacao, Telefone1, Telefone2, Celular, Valor_suporte, Pessoa) VALUES ('$Num_contrato','$Nome','$CNPJ','$Data','$Valor','$Forma_pag','$Status_suporte','$Obs','$Instalador','$Servicos','$Quant_comp','$Registros','$Cidade','$Endereco','$CEP','$Email','$Estado','$Complemento','$Bairro','$Situacao','$Telefone1','$Telefone2','$Celular','$Valor_suporte','$Pessoa')") or die("Erro no comando SQL:".mysql_error()); mysql_query("INSERT INTO historico(Id,User,Data,Acao) VALUES ('','$usuario',now(),'$msgconfirma')"); echo "<script language=\"javascript\" type=\"text/javascript\"> alert(\"Cliente cadastrado com Sucesso!!\"); location.href = 'financeiro.php'; </script>"; } if($erros > 0) { echo "<div align=center><font face=Arial color=#FFFFFF size=2><b>ATENÇÃO</b><br><br>Foram encontrados <b>$erros</b> erro(s) no cadastro do cliente:<br><b>$html_erros</b></br></br><a href='java script:history.go(-1)'><p>Voltar</p></a></font></div></br>"; } } ?> <html> <head> <title>Sistema de Controle</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> <!-- body { background-color: #262626; } a:link { color: #000000; text-decoration: none; } a:visited { color: #000000; text-decoration: none; } a:hover { text-decoration: underline; } a:active { text-decoration: none; } .style4 {font-size: 10px} .style7 {color: #FFFFFF} --> </style> <div align="center"> <p> </p> <p> </p> <table width="619" height="800" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td height="36" colspan="3" background="images/cima.png"> </td> </tr> <tr> <td width="9" height="647" background="images/esquerda.png"> </td> <td width="571"><form name="frm_clientes" method="post" action="<? echo $PHP_SELF; ?>"><table width="100%" height="100%" border="0" cellspacing="1" cellpadding="0" align="center"> <tr> <td height="29" colspan="3" bgcolor="#3E8BFF"><div align="center" class="style7"><font face="Arial" size="4"><b>Cadastro de Clientes</b></font></div></td> </tr> <tr> <td height="30" colspan="3"> </td> </tr> <tr> <td width="183" height="25"><div align="right"><font face="Arial" size="2">Numero do Contrato</font>:</div></td> <td width="19"> </td> <td width="365"><font face="Arial" size="2"> <input name="Num_contrato" type="text" id="Num_contrato" size="14" maxlength="14" /> </font></td> </tr> <tr> <td height="25"> <p align="right"><font face="Arial" size="2">Data de Contratacao</font>:</p></td> <td><label></label></td> <td><table width="309" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="14"><input type="text" name="dia" size="2" maxlength="2" /></td> <td width="10">/</td> <td width="12"><input type="text" name="mes" size="2" maxlength="2" /></td> <td width="10">/</td> <td width="31"><input type="text" name="ano" size="4" maxlength="4" /></td> <td width="232"><span class="style4"><font face="Arial">(dd/mm/aaaa)</font></span></td> </tr> </table></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Situacao do Contrato</font>:</div></td> <td><font face="Arial" size="2"> <label></label> </font></td> <td><font face="Arial" size="2"> <select name="Situacao" id="Situacao"> <option value="" selected="selected">Selecione</option> <option value="Novo">Novo</option> <option value="Renovacao">Renovacao</option> </select> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Pessoa</font>:</div></td> <td height="25"> </td> <td><label> <select name="Pessoa" id="Pessoa"> <option selected="selected">Selecione</option> <option value="Pessoa Fisica">Pessoa Fisica</option> <option value="Pessoa Juridica">Pessoa Juridica</option> </select> </label></td> </tr> <tr> <td height="22"><div align="right"><font face="Arial" size="2">CPF / CPNJ</font>:</div></td> <td height="22"> </td> <td><font face="Arial" size="2"> <input name="CNPJ" type="text" id="CNPJ" size="20" maxlength="14" /> </font><font face="Arial" class="style4">(ex: xx.xxx.xxx/xxxx-xx)</font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Nome / Classe Social</font>:</div></td> <td width="19"> </td> <td width="365"><font face="Arial" size="2"> <input type="text" name="Nome" size="20" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Endereco</font>:</div></td> <td> </td> <td><font face="Arial" size="2"> <input type="text" name="Endereco" size="20" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Complemento</font>:</div></td> <td> </td> <td><font face="Arial" size="2"> <input name="Complemento" type="text" id="Complemento" size="20" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Bairro</font>:</div></td> <td> </td> <td><font face="Arial" size="2"> <input name="Bairro" type="text" id="Bairro" size="20" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font size="2" face="Arial">Email</font>:</div></td> <td> </td> <td><font face="Arial" size="2"> <input name="Email" type="text" id="Email" size="20" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Cidade</font>:</div></td> <td> </td> <td><label> <input name="Cidade" type="text" id="Cidade" size="20" /> </label></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Estado</font>:</div></td> <td> </td> <td><label> <input name="Estado" type="text" id="Estado" size="20" /> </label></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">CEP</font>:</div></td> <td> </td> <td><font face="Arial" size="2"> <input name="CEP" type="text" id="CEP" size="20" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Telefone 1</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input name="Telefone1" type="text" id="Telefone1" size="20" maxlength="9" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Telefone 2</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input name="Telefone2" type="text" id="Telefone2" size="20" maxlength="9" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font size="2" face="Arial">Celular</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input name="Celular" type="text" id="Celular" size="20" maxlength="9" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Suporte</font>:</div></td> <td height="25"><label></label></td> <td><select name="Status_suporte" id="Status_suporte"> <option>Selecione</option> <option value="1">Sim</option> <option value="2">não</option> </select></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Valor</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input type="text" name="Valor" size="15" maxlength="12" id="Valor" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Valor Suporte</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input type="text" name="Valor_suporte" size="15" maxlength="12" id="Valor_suporte" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Forma de Pagamento</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input type="text" name="Forma_pag" size="15" maxlength="12" id="Forma_pag" /> </font></td> </tr> <tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Servicos Adquiridos</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input type="text" name="Servicos" size="15" maxlength="12" id="Servicos" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Instalador</font>:</div></td> <td height="25"><label></label></td> <td><select name="Instalador" id="Instalador"> <option>Selecione</option> <option value="Danilo">Danilo</option> <option value="William">William</option> </select></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Quant. de Computadores</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input type="text" name="Quant_comp" size="15" maxlength="12" id="Quant_comp" /> </font></td> </tr> <tr> <td height="25"><div align="right"><font face="Arial" size="2">Registro</font>:</div></td> <td height="25"> </td> <td><font face="Arial" size="2"> <input type="text" name="Registros" size="15" maxlength="12" id="Registros" /> </font><span class="style4"><font face="Arial">(Caso seja mais de um separar por /)</font></span></td> </tr> <tr> <td height="25" valign="top"><div align="right"><font face="Arial" size="2">Observacoes</font>:</div></td> <td height="25"><label></label></td> <td><textarea name="Obs" id="textarea" cols="40" rows="8"></textarea></td> </tr> <tr> <td height="62" colspan="3"><div align="center"> <p> </p> <p> <input type="submit" name="cadastrar" value="Cadastrar" /> </p> </div></td> </tr> </table> </form></td> <td width="7" background="images/direita.png"> </td> </tr> <tr> <td height="35" colspan="3" background="images/baixo.png"> </td> </tr> </table> </div> </body> </html>Link para o comentário
Compartilhar em outros sites
3 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.