
ramses
Membros-
Total de itens
4 -
Registro em
-
Última visita
Tudo que ramses postou
-
Desculpe pessoal, estou aprendendo PHP. Minha intenção é fazer um script de cadastramento para login. Porém não consigo inserir os dados. Ocorre sempre erro 500. Estou utilizando no Windows XP, Servidor local Apache 2.2, MySQL Server 5.0 e PHP 5. Os scripts são os seguintes: 3 (inc_dbConexao.php, CADASTRO.php, CADASTRO1.php) inc_dbConexao.php <?PHP $conexao = mysql_connect("localhost","root","123456"); $db = mysql_select_db("bd", $conexao); ?> CADASTRO.php html> <body> <p align="left"> <img src="cabecalho1.jpg" width="822" height="69" border="0"> <img src="imagem2.jpg" width="823" height="105" border="0"></font></p> <script language="javascript"> <!-- Valida campos do formulário --> function valida_form() { if (document.cadastro.txtnome.value == "") {alert("Por favor, preencha o campo [seu nome]."); cadastro.txtnome.focus(); return false; } if (document.cadastro.txtnick.value == "") {alert("Por favor, preencha o campo [nick]."); cadastro.txtnick.focus(); return false; } if (document.cadastro.txtmat.value == "") {alert("Por favor, preencha o campo [matrícula]."); cadastro.txtmat.focus(); return false; } if (document.cadastro.txtcargo.value == "") {alert("Por favor, preencha o campo [cargo]."); cadastro.txtcargo.focus(); return false; } if (document.cadastro.txtemail1.value == "") {alert("Por favor, preencha o campo [e-mail]."); cadastro.txtemail1.focus(); return false; } if (document.cadastro.txtemail2.value == "") {alert("Por favor, confirme [seu e-mail]."); cadastro.txtemail2.focus(); return false; } if (document.cadastro.txtsenha1.value == "") {alert("Por favor, preencha o campo [senha]."); cadastro.txtsenha1.focus(); return false; } if (document.cadastro.txtsenha2.value == "") {alert("Por favor, confirme [sua senha]."); cadastro.txtsenha2.focus(); return false; } if (document.cadastro.txtemail1.value != document.cadastro.txtemail2.value) {alert("O campo e-mail não confere com sua confirmação."); cadastro.txtemail1.focus(); return false; } if (document.cadastro.txtsenha1.value != document.cadastro.txtsenha2.value) {alert("O campo senha não confere com sua confirmação."); cadastro.txtsenha1.focus(); return false; } return true; } </script> <form name=cadastro" method="post" action="cadastro1.php" onsubmit="return valida_form(this);"> <div id="caixa_cad"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="45%" valign="top"><h6>CADASTRAR-ME NO SISTEMA</h6> <p> <label>Nome completo: </label> <input name="txtnome" type="text" class="caixa_texto" id="txtnome" size="50" maxlength="60" /> <strong></strong> Digite um nome entrada (nick): </label> <label></label> <input name="txtnick" type="text" class="caixa_texto" id="txtnick" size="20" maxlength="11" /> <strong></strong> </p></label> <p><label>Matrícula: </label><input name="txtmat" type="text" class="caixa_texto" id="txtrg" size="30" maxlength="14" /> <strong></strong> Digite seu cargo: </label><input name="txtcargo" type="text" class="caixa_texto" id="txtcargo" size="30" maxlength="30" /> <p><label>E-mail: </label><input name="txtemail1" type="text" class="caixa_texto" size="35" maxlength="60" /> <label><strong></strong> Confirme o e-mail: </label><input name="txtemail2" type="text" class="caixa_texto" size="35" maxlength="60" /> *</p> <p><label>Senha: </label><input name="txtsenha1" type="password" class="caixa_texto" id="txtsenha_1" size="10" maxlength="10" /> * (mínimo de 5 caracteres) <label>Confirme a senha: </label> <input name="txtsenha2" type="password" class="caixa_texto" id="txtsenha_2" size="10" maxlength="10" /> * <input type="submit" class="botao" name="submit222" value="Cadastrar-me" /> </p> <p align="right"> <input type="hidden" name="verifica_erro" value="S" /> <input type="image" name="imageField" src="imagens/btn_continuar.gif" /> </p> </div> </form> </td> </body> </html> CADASTRO1.php <?php include "inc_dbconexao.php"; $nome = trim($_POST['txtnome]); $nick = trim($_POST['txtnick']); $email = trim($_POST['txtemail2']); $mat = trim($_POST['txtmat']); $cargo = trim($_POST['txtcargo']); $senha = trim($_POST['txtsenha2']); /* Vamos checar se o nome de Usuário escolhido e/ou Email já existem no banco de dados */ $sql_email_check = mysql_query( "SELECT * FROM users WHERE email='{$email}'" ); $sql_nome_check = mysql_query( "SELECT * FROM users WHERE nome='{$nome}'" ); $sql_mat_check = mysql_query( "SELECT * FROM users WHERE mat='{$mat}'" ); $sql_nick_check = mysql_query( "SELECT * FROM users WHERE nick='{$nick}'" ); $eReg = mysql_fetch_array($sql_email_check); $nReg = mysql_fetch_array($sql_nome_check); $mReg = mysql_fetch_array($sql_mat_check); $kReg = mysql_fetch_array($sql_nick_check); $email_check = $eReg[0]; $nome_check = $uReg[0]; $mat_check = $mReg[0]; $nick_check = $kReg[0]; if (($email_check > 0) || ($nome_check > 0) || ($mat_chec > 0) || ($nick_chec > 0) { echo "<strong>ERRO</strong>: <br /><br />"; if ($email_check > 0){ echo "Este email já está sendo utilizado.<br /><br />"; unset($email); } if ($nome_check > 0){ echo "Este nome de usuário já está sendo utilizado.<br /><br />"; unset($nome); } if ($mat_check > 0){ echo "Esta matrícula já está sendo utilizada.<br /><br />"; unset($mat); } if ($nick_check > 0){ echo "Este nick de usuário já está sendo utilizado.<br /><br />"; unset($nick); } include "cadastro.php"; }else{ // Inserindo os dados no banco de dados $info = htmlspecialchars($info); $sql = mysql_query( "INSERT INTO users (nome, nick, email, mat, cargo, senha ) VALUES ('$nome', '$nick', '$email', '$mat', '$cargo', '$senha'") or die( mysql_error() ); if (!$sql){ echo "Ocorreu um erro ao criar sua conta, entre em contato."; }else{ echo "Cadastrado com sucesso"; } } ?> Onde estará o erro? Espero que alguém possa me ajudar. Obrigado.
-
Refaço o tópico pois talvez não tenha me fazido entender: Tento fazer dois scripts em ASP para montar um formulário que servirá para o usuário inserir dados. Alguns dos campos entretanto já estarão pré-preenchidos através de dados resgatados de uma tabela de um Banco de Dados ACCESS. Os parâmetros são definidos em um formulário anterior e retornados através de uma instrução request. O objetivo disto é para que os campos PROCESSO, NOME e ENDEREÇO (no SCRIPT 1) já estejam pré-prenchidos quando o usuário for inserir os dados complementares. A busca funciona só que, só consigo resgatar a primeira palavra de cada campo e não o campo inteiro. Por exemplo Só que so consigo buscar a primeira palavra de cada campo. Por exemplo, no campo DENUNCIADO, se está cadastrado "JOSÉ DA SILVA SANTOS" eu só consigo buscar "JOSÉ". Se no campo ENDER está cadastrado "RUA DAS ALELUIAS, 113", o formulário só retorna "RUA" e assim por diante... Posto os scripts abaixo, informando que o no SCRIPT 1, "PROCESSO" é um campo alfa-númérico e no SCRIT 2, "Cod1" é um campo numérico. Obrigado! SCRIPT 1 <%@ CodePage=1252 Language="VBScript"%> <% Option Explicit %> <!-- #INCLUDE file="FCKeditor/fckeditor.asp" --> <!--#Include file="../dbConex.inc"--> <% DIM conexaoDataBase, x, cod cod = request.querystring("cod") DIM sqlPrinc, rsPrinc, estilo Call AbreConexao sqlPrinc = "SELECT * " SQLPrinc = sqlPrinc + "FROM TabelaPRINCIPAL WHERE PROCESSO = '" +cod+ "' " Set rsPrinc = conexaoDataBase.Execute(sqlPrinc) %> <html> <head> <%If not rsPrinc.eof then%> <title>Processo</title> <title>DESPACHO</title> </head> <body> <p><b><font size="6">PROCESSO <% = rsPrinc("PROCESSO") %></font></b></p> <form name="formdespacho" method="POST" ACTION="respnova.asp"onSubmit="return validaForm(this);"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td> PROCESSO: </td> <td><input type="text" value=<% = rsPrinc("PROCESSO") %> name="processo" size="0"> <td width="20%"> FISCAL: </td> <td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr> </tr> <tr> <td>NOME: </td> <td><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="60"></td> <tr/> <td width="20%">ENDEREÇO: <td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="60"></td> <input type="submit" value="Inserir" name="btInsere"> <input type="reset" value="Limpar campos" name="btLimpa"> <a href="DESPACHAR.asp" class="link"> INICIAL </a> <a href="Imprimindo1.asp" class="link"> IMPRIMIR OU ALTERAR DESPACHOS</a> </td> </tr> <% Dim oFCKeditor Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = "/FCKeditor/" oFCKeditor.Create "FCKeditor1" %> </table> </form> </body> </html> <%end if%> <% rsPrinc.Close Call fechaConexao Set rsPrinc = Nothing %> SCRIPT 2 <%@ CodePage=1252 Language="VBScript"%> <% Option Explicit %> <!-- #INCLUDE file="FCKeditor/fckeditor.asp" --> <!--#Include file="../dbConex.inc"--> <% DIM conexaoDataBase, x, cod cod = request("cod") DIM sqlPrinc, rsPrinc, estilo Call AbreConexao sqlPrinc = "SELECT * FROM DENUNCIA WHERE Cod1 ="+cod Set rsPrinc = conexaoDataBase.Execute(sqlPrinc) %> <html> <head> <%If not rsPrinc.eof then%> <title>Responder Denúncia</title> <title>DESPACHO</title> </SCRIPT> </head> <body> <table> <p><b><font size="6"> DENUNCIA Nº <% = rsPrinc("Cod1") %></font></b></p> <form name="formdespacho" method="POST" ACTION="insrespden1.asp" onSubmit="return validaForm(this);"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="20%"> DENUNCIA Nº: </td> <td width="80%"><input type="text" value=<% = rsPrinc("Cod1") %> name="Cod1" size="0"> <td width="20%"> FISCAL: </td> <td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr> <tr> <td width="20%">NOME: </td> <td width="80%"><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="40"></td> <tr/> <tr> <td width="20%">ENDEREÇO: <td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="40"></td> <td width="20%">NÚMERO: <td width="80%"><input type="text" value=<% = rsPrinc("NUM") %> name="num" size="10"></td></tr> <tr> <td width="20%">COMPLEMENTO: <td width="80%"><input type="text" value=<% = rsPrinc("comp") %> name="comp" size="30"></td> <td width="20%">BAIRRO: <td width="80%"><input type="text" value=<% = rsPrinc("Bairro") %> name="Bairro" size="20"></td> </br> </tr> <tr> <td width="20%">ASSUNTO: <td width="80%"><input type="text" value=<% = rsPrinc("Assunto") %> name="Assunto" size="30"></td> <td width="20%">ORIGEM: <td width="80%"><input type="text" value=<% = rsPrinc("Origem") %> name="Origem" size="20"></td> <td width="20%">DOC: <td width="80%"><input type="text" value=<% = rsPrinc("Doc") %> name="Doc" size="10"></td> </br> </tr> <tr> <td width="20%">DENÚNCIA: <td width="80%"><input type="text" value=<% = rsPrinc("Denuncia") %> name="Denuncia" size="40"></td> <input type="submit" value="Inserir" name="btInsere"> <input type="reset" value="Limpar campos" name="btLimpa"> <a href="DESPACHAR.asp" class="link"> INICIAL </a> <a href="Denunciasresp.asp" class="link"> IMPRIMIR OU ALTERAR RESPOSTAS</a> </tr> <% Dim oFCKeditor Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = "/FCKeditor/" oFCKeditor.Create "FCKeditor1" %> </table> </form> </body> <%end if%> <% rsPrinc.Close Call fechaConexao Set rsPrinc = Nothing %>
-
Desculpe. Talvez eu não tenha sido muito claro. Tenho um formulário para inserir dados. Alguns destes dados entretanto eu resgato de uma tabela do mesmo Banco de Dados Access em que eu vou realizar a inserção, porém lógico, de tabela distinta. Esta última etapa está funcionando perfeitamente, ou seja os dados estão sendo inseridos. Na primeira etapa entretanto eu tento resgatar os dados da tabela de origem já que eles também estarão presentes nesta outra. Só que so consigo buscar a primeira palavra de cada campo. Por exemplo, no campo DENUNCIADO, se está cadastrado "JOSÉ DA SILVA SANTOS" eu só consigo buscar "JOSÉ". Se no campo ENDER está cadastrado "RUA DAS ALELUIAS, 113", o formulário só retorna "RUA" e assim por diante...Não sei se me fiz entender agora...Se for necessário, posto novamente. Obrigado.
-
Esqueci de dizer o principal ...só consigo buscar a primeira letra de cada campo, não retorna o campo inteiro. Post novamente abaixo: Bom dia! Espero contar com a ajuda de vocês. Meu erro deve ser banal mas, como estou apreendendo através de um livro e, ali não encontrei a solução, recorro a alguém mais experiente. Tento fazer dois scripts em ASP para montar um formulário que servirá para o usuário inserir dados. Alguns dos campos entretanto já estarão pré-preenchidos através de dados resgatados de uma tabela de um Banco de Dados ACCESS. A busca funciona só que, só consigo resgatar a primeira palavra de cada campo e não o campo inteiro. Posto os scripts abaixo, informando que o no SCRIPT 1, "PROCESSO" é um campo alfa-númérico e no SCRIT 2, "Cod1" é um campo numérico. Obrigado! SCRIPT 1 <%@ CodePage=1252 Language="VBScript"%> <% Option Explicit %> <!-- #INCLUDE file="FCKeditor/fckeditor.asp" --> <!--#Include file="../dbConex.inc"--> <% DIM conexaoDataBase, x, cod cod = request.querystring("cod") DIM sqlPrinc, rsPrinc, estilo Call AbreConexao sqlPrinc = "SELECT * " SQLPrinc = sqlPrinc + "FROM TabelaPRINCIPAL WHERE PROCESSO = '" +cod+ "' " Set rsPrinc = conexaoDataBase.Execute(sqlPrinc) %> <html> <head> <%If not rsPrinc.eof then%> <title>Processo</title> <title>DESPACHO</title> <script LANGUAGE="JAVASCRIPT"> function validaForm() { if (document.formdespacho.despacho.value.length <1) {alert("O campo DESPACHO não pode ficar em branco."); formdespacho.despacho.focus(); return false; } if (document.formdespacho.processo.value.length <1) {alert("O campo PROCESSO não pode ficar em branco."); formdespacho.processo.focus(); return false; } if (document.formdespacho.fiscal.value.length <1) {alert("O campo FISCAL não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } return true; } </SCRIPT> </head> <body> <p><b><font size="6">PROCESSO <% = rsPrinc("PROCESSO") %></font></b></p> <form name="formdespacho" method="POST" ACTION="respnova.asp"onSubmit="return validaForm(this);"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td> PROCESSO: </td> <td><input type="text" value=<% = rsPrinc("PROCESSO") %> name="processo" size="0"> <td width="20%"> FISCAL: </td> <td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr> </tr> <tr> <td>NOME: </td> <td><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="60"></td> <tr/> <td width="20%">ENDEREÇO: <td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="60"></td> <input type="submit" value="Inserir" name="btInsere"> <input type="reset" value="Limpar campos" name="btLimpa"> <a href="DESPACHAR.asp" class="link"> INICIAL </a> <a href="Imprimindo1.asp" class="link"> IMPRIMIR OU ALTERAR DESPACHOS</a> </td> </tr> <% Dim oFCKeditor Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = "/FCKeditor/" oFCKeditor.Create "FCKeditor1" %> </table> </form> </body> </html> <%end if%> <% rsPrinc.Close Call fechaConexao Set rsPrinc = Nothing %> SCRIPT 2 <%@ CodePage=1252 Language="VBScript"%> <% Option Explicit %> <!-- #INCLUDE file="FCKeditor/fckeditor.asp" --> <!--#Include file="../dbConex.inc"--> <% DIM conexaoDataBase, x, cod cod = request("cod") DIM sqlPrinc, rsPrinc, estilo Call AbreConexao sqlPrinc = "SELECT * FROM DENUNCIA WHERE Cod1 ="+cod Set rsPrinc = conexaoDataBase.Execute(sqlPrinc) %> <html> <head> <%If not rsPrinc.eof then%> <title>Responder Denúncia</title> <title>DESPACHO</title> <script LANGUAGE="JAVASCRIPT"> function validaForm() { if (document.formdespacho.despacho.value.length <1) {alert("O campo DESPACHO não pode ficar em branco."); formdespacho.despacho.focus(); return false; } if (document.formdespacho.processo.value.length <1) {alert("O campo PROCESSO não pode ficar em branco."); formdespacho.processo.focus(); return false; } if (document.formdespacho.fiscal.value.length <1) {alert("O campo FISCAL não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } if (document.formdespacho.denunciado.value.length <1) {alert("O campo DENUNCIADO não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } if (document.formdespacho.ender.value.length <1) {alert("O campo ENDEREÇO não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } if (document.formdespacho.num.value.length <1) {alert("O campo NÚMERO não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } return true; } </SCRIPT> </head> <body> <table> <p><b><font size="6"> DENUNCIA Nº <% = rsPrinc("Cod1") %></font></b></p> <form name="formdespacho" method="POST" ACTION="insrespden1.asp" onSubmit="return validaForm(this);"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="20%"> DENUNCIA Nº: </td> <td width="80%"><input type="text" value=<% = rsPrinc("Cod1") %> name="Cod1" size="0"> <td width="20%"> FISCAL: </td> <td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr> <tr> <td width="20%">NOME: </td> <td width="80%"><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="40"></td> <tr/> <tr> <td width="20%">ENDEREÇO: <td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="40"></td> <td width="20%">NÚMERO: <td width="80%"><input type="text" value=<% = rsPrinc("NUM") %> name="num" size="10"></td></tr> <tr> <td width="20%">COMPLEMENTO: <td width="80%"><input type="text" value=<% = rsPrinc("comp") %> name="comp" size="30"></td> <td width="20%">BAIRRO: <td width="80%"><input type="text" value=<% = rsPrinc("Bairro") %> name="Bairro" size="20"></td> </br> </tr> <tr> <td width="20%">ASSUNTO: <td width="80%"><input type="text" value=<% = rsPrinc("Assunto") %> name="Assunto" size="30"></td> <td width="20%">ORIGEM: <td width="80%"><input type="text" value=<% = rsPrinc("Origem") %> name="Origem" size="20"></td> <td width="20%">DOC: <td width="80%"><input type="text" value=<% = rsPrinc("Doc") %> name="Doc" size="10"></td> </br> </tr> <tr> <td width="20%">DENÚNCIA: <td width="80%"><input type="text" value=<% = rsPrinc("Denuncia") %> name="Denuncia" size="40"></td> <input type="submit" value="Inserir" name="btInsere"> <input type="reset" value="Limpar campos" name="btLimpa"> <a href="DESPACHAR.asp" class="link"> INICIAL </a> <a href="Denunciasresp.asp" class="link"> IMPRIMIR OU ALTERAR RESPOSTAS</a> </tr> <% Dim oFCKeditor Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = "/FCKeditor/" oFCKeditor.Create "FCKeditor1" %> </table> </form> </body> <%end if%> <% rsPrinc.Close Call fechaConexao Set rsPrinc = Nothing %>