Não to conseguindo fazer a alteração de senhas no site, quando coloco a senha atual, a nova e a confirmação da mesma o site direciona para outra página que contem as mensagens e mostra a mensagem "Ocorreu um erro inesperado ao alterar senha! " que é referente a função validar que esta em vermelho ai em baixo.
Pergunta
ValterJunior
Boa Tarde pessoal,
Não to conseguindo fazer a alteração de senhas no site, quando coloco a senha atual, a nova e a confirmação da mesma o site direciona para outra página que contem as mensagens e mostra a mensagem "Ocorreu um erro inesperado ao alterar senha! " que é referente a função validar que esta em vermelho ai em baixo.
Preciso da ajuda de vocês urgente.
At.
Valter Júnior
alterasenha.asp
<html> <head> <title>Altera Senha</title> <style type="text/css"> <!-- A:link {color: ##0066CC; text-decoration:none;} A:visited {color: #0066CC; text-decoration:none;} A:hover {color:#FF9900; text-decoration:none;} .bordaGeral { border: 1px solid #666666; } .bordaTopo { border-top-width: 1px; border-right-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: none; border-left-style: solid; border-top-color: #666666; border-right-color: #666666; border-left-color: #666666; } .bordaSimplesTop { border-top-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #CCCCCC; } .titulo { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: 800; font-variant: normal; color: #0066CC; } .comentario { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: 900; font-variant: normal; color: #FF9900; background-position: center center; padding: 2px; } body { margin-left: 0px; margin-top: 0px; } .style1 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; } .style4 { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #FF0000; } .style6 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #000099; } --> </style> <script language="JavaScript"><!-- var hellotext=" Copyright © 2008 - DIVIDATA Processamento de Dados Ltda - Todos os direitos reservados " var thetext="" var started=false var step=0 var times=1 function welcometext() { times-- if (times==0) { if (started==false) { started = true; window.status = hellotext; setTimeout("anim()",1); } thetext = hellotext; } } function showstatustext(txt) { thetext = txt; setTimeout("welcometext()",4000) times++ } function anim() { step++ if (step==12) {step=1} if (step==1) {window.status='>>=========='+thetext+'==========<<'} if (step==2) {window.status='=>>========='+thetext+'=========<<='} if (step==3) {window.status='==>>========'+thetext+'========<<=='} if (step==4) {window.status='===>>======='+thetext+'=======<<==='} if (step==5) {window.status='====>>======'+thetext+'======<<===='} if (step==6) {window.status='=====>>====='+thetext+'=====<<====='} if (step==7) {window.status='======>>===='+thetext+'====<<======'} if (step==8) {window.status='=======>>==='+thetext+'===<<======='} if (step==9) {window.status='========>>=='+thetext+'==<<========'} if (step==10) {window.status='=========>>='+thetext+'=<<========='} if (step==11) {window.status='==========>>'+thetext+'<<=========='} setTimeout("anim()",100); } welcometext(); // --></script> </head> <body bgcolor="#FFFFFF" text="#000080" link="#000080" vlink="#000080" alink="#000080" topmargin="0" leftmargin="0"> <table width="906" height="108" border="0" align="center" class="bordaGeral"> <tr> <td background="Img/banner.jpg"><table width="200" border="0"> <tr> <td><img src="Img/logo_topo.gif" alt="." width="238" height="34"><br> <img src="Img/logo_down.gif" alt="." width="238" height="34"></td> </tr> </table> <br></td> </tr> </table> <table width="909" border="0" align="center"> <tr> <td width="269" class="style1"><div align="left" class="style1"> <script language=JavaScript class="style98"> hoje = new Date() dia = hoje.getDate() dias = hoje.getDay() mes = hoje.getMonth() ano = hoje.getYear() if (dia < 10) dia = "0" + dia if (ano < 2000) ano = "19" + ano function CriaArray (n) { this.length = n } NomeDia = new CriaArray(7) NomeDia[0] = "Domingo" NomeDia[1] = "Segunda-feira" NomeDia[2] = "Terça-feira" NomeDia[3] = "Quarta-feira" NomeDia[4] = "Quinta-feira" NomeDia[5] = "Sexta-feira" NomeDia[6] = "Sábado" // NomeMes = new CriaArray(12) NomeMes[0] = "Janeiro" NomeMes[1] = "Fevereiro" NomeMes[2] = "Março" NomeMes[3] = "Abril" NomeMes[4] = "Maio" NomeMes[5] = "Junho" NomeMes[6] = "Julho" NomeMes[7] = "Agosto" NomeMes[8] = "Setembro" NomeMes[9] = "Outubro" NomeMes[10] = "Novembro" NomeMes[11] = "Dezembro" document.write ("Divinópolis/MG - " + dia + " de " + NomeMes[mes] + " de " + ano + ".</font>") </script> </div></td> <td width="49" class="style1"><font color="#000000">Usuário:</font></td> <td width="197" class="style1"><span class="style4"><%=session("login")%></span></td> <td width="99" class="style1"><span class="style4"> </span>Nível de Acesso:</td> <td width="194" class="style1"><span class="style4"><%=session("nivel_acesso")%></span></td> <td width="42" class="style1"><font color="#000000">Versão:</font></td> <td width="29" class="style4"><div align="left">1.3.1</div></td> </tr> </table> <table width="909" border="0" align="center"> <tr> <td><br> <img src="Img/icone_logout.jpg" alt="Cadastramento de Senhas" width="48" height="48" align="absmiddle"> <span class="style4">Alterar Senha</span></td> </tr> </table> <div align="left"><br> <br> <form name="form1" method="post" action="alterarsenha_grava.asp"> <div align="left"> </div> <table border="0" cellpadding="5" cellspacing="5" width="240"> <tr> <td align=center colspan="2" width="240"> <Font face=Tahoma size=1><b><font color="#000000">Usuário: </font><font face="Tahoma, Comic Sans MS" color="#000000" size="1"></font><font color="#000000"> </font> </b></font> <span class="style6"><%=session("login")%></span></td> </tr> <tr> <td align=right width="120"> <Font color="#000000" size=1 face=Tahoma>Senha Atual:</font> </td> <td width="120"> <font size="1" face="Tahoma"> <input type="password" maxlength="10" size="12" name="txtSenhaAtual"> </font></td> </tr> <tr> <td align=right width="120"> <Font color="#000000" size=1 face=Tahoma>Nova Senha:</font> </td> <td width="120"> <font size="1" face="Tahoma"> <input type="password" maxlength="10" size="12" name="txtNovaSenha"> </font></td> </tr> <tr> <td align=right width="120"> <Font color="#000000" size=1 face=Tahoma>Confirmação:</font> </td> <td width="120"> <font size="1" face="Tahoma"> <input name="txtConfirmacao" type="password" id="txtConfirmacao" size="12" maxlength="10"> </font></td> </tr> <tr> <td align=center colspan=2 width="240"> <input type="submit" name="cmdAlterar" value="Alterar"> </td> </tr> </table> </form> <span style="font-family: Arial"> </span><br> </div> <p align="center"><a href="menu.asp"><img src="Img/Voltar.gif" alt="Voltar" width="52" height="21" border="0"></a></p> </body> </html> <html> <head> <title>Altera Senha</title> <style type="text/css"> <!-- A:link {color: ##0066CC; text-decoration:none;} A:visited {color: #0066CC; text-decoration:none;} A:hover {color:#FF9900; text-decoration:none;} .bordaGeral { border: 1px solid #666666; } .bordaTopo { border-top-width: 1px; border-right-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: none; border-left-style: solid; border-top-color: #666666; border-right-color: #666666; border-left-color: #666666; } .bordaSimplesTop { border-top-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #CCCCCC; } .titulo { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: 800; font-variant: normal; color: #0066CC; } .comentario { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: 900; font-variant: normal; color: #FF9900; background-position: center center; padding: 2px; } body { margin-left: 0px; margin-top: 0px; } .style1 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; } .style2 { font-family: Arial, Helvetica, sans-serif; font-size: 10px; } .style4 { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #FF0000; } --> </style> <script language="JavaScript"><!-- var hellotext=" Copyright © 2008 - DIVIDATA Processamento de Dados Ltda - Todos os direitos reservados " var thetext="" var started=false var step=0 var times=1 function welcometext() { times-- if (times==0) { if (started==false) { started = true; window.status = hellotext; setTimeout("anim()",1); } thetext = hellotext; } } function showstatustext(txt) { thetext = txt; setTimeout("welcometext()",4000) times++ } function anim() { step++ if (step==12) {step=1} if (step==1) {window.status='>>=========='+thetext+'==========<<'} if (step==2) {window.status='=>>========='+thetext+'=========<<='} if (step==3) {window.status='==>>========'+thetext+'========<<=='} if (step==4) {window.status='===>>======='+thetext+'=======<<==='} if (step==5) {window.status='====>>======'+thetext+'======<<===='} if (step==6) {window.status='=====>>====='+thetext+'=====<<====='} if (step==7) {window.status='======>>===='+thetext+'====<<======'} if (step==8) {window.status='=======>>==='+thetext+'===<<======='} if (step==9) {window.status='========>>=='+thetext+'==<<========'} if (step==10) {window.status='=========>>='+thetext+'=<<========='} if (step==11) {window.status='==========>>'+thetext+'<<=========='} setTimeout("anim()",100); } welcometext(); // --></script> </head> <body bgcolor="#FFFFFF" text="#000080" link="#000080" vlink="#000080" alink="#000080" topmargin="0" leftmargin="0"> <table width="906" height="108" border="0" align="center" class="bordaGeral"> <tr> <td background="Img/banner.jpg"><table width="200" border="0"> <tr> <td><img src="Img/logo_topo.gif" alt="." width="238" height="34"><br> <img src="Img/logo_down.gif" alt="." width="238" height="34"></td> </tr> </table> <br></td> </tr> </table> <table width="909" border="0" align="center"> <tr> <td width="269" class="style1"><div align="left" class="style1"> <script language=JavaScript class="style98"> hoje = new Date() dia = hoje.getDate() dias = hoje.getDay() mes = hoje.getMonth() ano = hoje.getYear() if (dia < 10) dia = "0" + dia if (ano < 2000) ano = "19" + ano function CriaArray (n) { this.length = n } NomeDia = new CriaArray(7) NomeDia[0] = "Domingo" NomeDia[1] = "Segunda-feira" NomeDia[2] = "Terça-feira" NomeDia[3] = "Quarta-feira" NomeDia[4] = "Quinta-feira" NomeDia[5] = "Sexta-feira" NomeDia[6] = "Sábado" // NomeMes = new CriaArray(12) NomeMes[0] = "Janeiro" NomeMes[1] = "Fevereiro" NomeMes[2] = "Março" NomeMes[3] = "Abril" NomeMes[4] = "Maio" NomeMes[5] = "Junho" NomeMes[6] = "Julho" NomeMes[7] = "Agosto" NomeMes[8] = "Setembro" NomeMes[9] = "Outubro" NomeMes[10] = "Novembro" NomeMes[11] = "Dezembro" document.write ("Divinópolis/MG - " + dia + " de " + NomeMes[mes] + " de " + ano + ".</font>") </script> </div></td> <td width="49" class="style1"><font color="#000000">Usuário:</font></td> <td width="197" class="style1"><span class="style4"><%=session("login")%></span></td> <td width="99" class="style1"><span class="style4"> </span>Nível de Acesso:</td> <td width="194" class="style1"><span class="style4"><%=session("nivel_acesso")%></span></td> <td width="42" class="style1"><font color="#000000">Versão:</font></td> <td width="29" class="style4"><div align="left">1.3.1</div></td> </tr> </table> <table width="909" border="0" align="center"> <tr> <td><br> <img src="Img/icone_logout.jpg" alt="Cadastramento de Senhas" width="48" height="48" align="absmiddle"> <span class="style4">Alterar Senha</span></td> </tr> </table> <p> <div align="left"></div> <% '***Declarando Conexões com Banco de Dados*** Set Conn = Server.CreateObject("AdoDb.Connection") Conn.provider="Microsoft.Jet.OLEDB.4.0" Conn.connectionstring=Server.Mappath("Dados/os.mdb") Conn.open %> <% Dim SenhaAtual Dim NovaSenha Dim Confirmacao SenhaAtual = Request.Form("txtSenhaAtual") NovaSenha = Request.Form("txtNovaSenha") Confirmacao = Request.Form("txtConfirmacao") CODE if ValidarCampos(SenhaAtual,NovaSenha,Confirmacao) then if AlteraSenha(Session("login"),NovaSenha) then session("Mensagem") = "Senha Alterada Com Sucesso!" else session("Mensagem") = "Ocorreu um erro inesperado ao alterar senha!" end if Response.Redirect "mensagem.asp" end if CODE private function ValidarCampos(iSenhaAtual,iNovaSenha,iConfirmacao) If iSenhaAtual = Empty then Session("Mensagem") = "Informe a Senha Atual!" & " - ==>" & Session("senha") Response.Redirect "mensagem.asp" End If if iNovaSenha = empty then Session("Mensagem") = "Informe a nova Senha!" Response.Redirect "mensagem.asp" end if if iConfirmacao = empty then Session("Mensagem") = "Informe a confirmação da nova Senha!" Response.Redirect "mensagem.asp" end if if iNovaSenha <> iConfirmacao then Session("Mensagem") = "A confirmação ou a Nova Senha está incorreta!<BR> Redigite-a." Response.Redirect "mensagem.asp" end if if not len(iNovaSenha)>=6 then Session("Mensagem") = "A senha deve ter pelo menos 6 caracteres!<BR> Redigite-a." Response.Redirect "mensagem.asp" end if ValidarCampos = True end function Private Function AlteraSenha(ilogin,isenha) on error resume next Dim BDSiate Dim RecUsuario '-------------------------------------- Dim SQLString set BDSiate = Server.CreateObject("ADODB.Connection") set RecUsuario = Server.CreateObject("ADODB.Recordset") BDSiate.ConnectionString = ConexaoBD BDSiate.Open SQLString = "Update usuarios Set senha='" & CriptografarHex(isenha) & "' WHERE " & _ "login = " & ilogin RecUsuario.ActiveConnection = BDSiate RecUsuario.CursorType = 3 RecUsuario.LockType = 1 RecUsuario.Source = SQLString RecUsuario.Open if Err.number = 0 then AlteraSenha = True else AlteraSemha = False end if End Function %> <br> <br> <p align="center" class="style1"><a href="menu.asp"><img src="Img/Voltar.gif" alt="Voltar" width="52" height="21" border="0"></a></p> </body> </html>Link para o comentário
Compartilhar em outros sites
5 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.