Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

vitorlouzada

Erro no código

Recommended Posts

Pessoal, que que pode estar acontecendo nesse código que valida o login e se o login estiver correto ele grava um item no banco de dados. Segue código:

 

<% Set Conexao = CreateObject("ADODB.CONNECTION")
ConStr = "DBQ=C:\Inetpub\wwwroot\emplacart\pedidos\inclusao_pedidos\bd\bd.mdb;Driver={Microsoft Access Driver (*.mdb)};"
ConexaoAberta = FALSE
Sub AbreConexao()
	if not ConexaoAberta then
	Conexao.Open ConStr
	ConexaoAberta = True
	end if
end sub
Sub FechaConexao()
	if ConexaoAberta then
	Conexao.close
	ConexaoAberta = False
	end if
end sub %>
  
  <% AbreConexao
	login = Replace(request.form("admin"), "'", "/")
   senha = Replace(request.form("senha"), "'", "/")
	function limpalogin(str)
str = trim(str)
str = lcase(str)
str = replace(str,"=","")
str = replace(str,"'","")
str = replace(str,"""""","")
str = replace(str," or ","")
str = replace(str," and ","")
str = replace(str,"(","")
str = replace(str,")","")
str = replace(str,"<","[")
str = replace(str,">","]")
str = replace(str,"update","")
str = replace(str,"-shutdown","")
str = replace(str,"--","")
str = replace(str,"'","")
str = replace(str,"#","")
str = replace(str,"$","")
str = replace(str,"%","")
str = replace(str,"¨","")
str = replace(str,"&","")
str = replace(str,"'or'1'='1'","")
str = replace(str,"--","")
str = replace(str,"insert","")
str = replace(str,"drop","")
str = replace(str,"delet","")
str = replace(str,"xp_","")
str = replace(str,"select","")
str = replace(str,"*","")
limpalogin = str
end function
	Sql = "SELECT * FROM users WHERE login = '"&login&"' "
	Sql = Sql & "AND senha='"&senha&"' "
	Set Rs = Conexao.Execute(Sql)
	if not rs.eof then
	Session("yep") = True
	Session("id") = RS("id")
	Session("admin") = RS("login")
	Session("email") = RS("email")
	Session("nivel") = RS("nivel")
	Session("ip_admin") = Request.ServerVariables("REMOTE_ADDR")
		else
	Response.Redirect "falha.asp"
	end if 
		if  rs.eof then
	Session("yep") = True
	Session("id") = RS("id")
	Session("admin") = RS("login")
	Session("email") = RS("email")
	Session("nivel") = RS("nivel")
	Session("ip_admin") = Request.ServerVariables("REMOTE_ADDR")
		else
	request.form("enviado") = "sim" Then
Cadastrado =False
set Dicionario = CreateObject("scripting.dictionary")
i = 0

Sql = "SELECT status FROM pedido WHERE status = '"&Request.form("status")&"'"
set Rs =Conexao.Execute(Sql)


Vet = Dicionario.items
if Dicionario.Count<>0 then
Response.Write "<b><center><font face=verdana size=1>"
Response.Write "O(s) seguintes dado(s) está(ão) incorreto(s)<BR><br>"
for i = 0 to Dicionario.Count - 1
Response.Write vet(i) & "<BR><br>"
next
response.write "<BR><br>"

Else
Sql = "INSERT INTO pedido (status)"
Sql = Sql & "VALUES('" & Request.Form("status") & "')" 
Conexao.Execute(Sql)
Cadastrado = True
End If
End If
If Cadastrado = False Then 
Else
end if
 fecha conexao%>

O erro que está dando é:

 

Tipo de erro:

Erro de compilação do Microsoft VBScript (0x800A0401)

Fim da instrução esperado

/emplacart/pedidos/inclusao_pedidos/concluir.asp, line 73, column 32

request.form("enviado") = "sim" Then

 

Linha 73:

request.form("enviado") = "sim" Then

 

Me ajudem por favor!!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não ta faltando um if nessa linha do erro não?

 

 

if (request.form("enviado")) = "sim" Then
Cadastrado =False
end if

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu fiz algumas alterações no código e não está dando erro... porém não está salvando no banco de dados....

 

segue o código alterado:

<% @ LANGUAGE="VBSCRIPT" %>
<% Set Conexao = CreateObject("ADODB.CONNECTION")
ConStr = "DBQ=C:\Inetpub\wwwroot\emplacart\pedidos\inclusao_pedidos\bd\bd.mdb;Driver={Microsoft Access Driver (*.mdb)};"
ConexaoAberta = FALSE
Sub AbreConexao()
	if not ConexaoAberta then
	Conexao.Open ConStr
	ConexaoAberta = True
	end if
end sub
Sub FechaConexao()
	if ConexaoAberta then
	Conexao.close
	ConexaoAberta = False
	end if
end sub %>
  
  <% AbreConexao
	login = Replace(request.form("admin"), "'", "/")
   senha = Replace(request.form("senha"), "'", "/")
	function limpalogin(str)
str = trim(str)
str = lcase(str)
str = replace(str,"=","")
str = replace(str,"'","")
str = replace(str,"""""","")
str = replace(str," or ","")
str = replace(str," and ","")
str = replace(str,"(","")
str = replace(str,")","")
str = replace(str,"<","[")
str = replace(str,">","]")
str = replace(str,"update","")
str = replace(str,"-shutdown","")
str = replace(str,"--","")
str = replace(str,"'","")
str = replace(str,"#","")
str = replace(str,"$","")
str = replace(str,"%","")
str = replace(str,"¨","")
str = replace(str,"&","")
str = replace(str,"'or'1'='1'","")
str = replace(str,"--","")
str = replace(str,"insert","")
str = replace(str,"drop","")
str = replace(str,"delet","")
str = replace(str,"xp_","")
str = replace(str,"select","")
str = replace(str,"*","")
limpalogin = str
end function
	Sql = "SELECT * FROM users WHERE login = '"&login&"' "
	Sql = Sql & "AND senha='"&senha&"' "
	Set Rs = Conexao.Execute(Sql)
	if not rs.eof then
	Session("yep") = True
	Session("id") = RS("id")
	Session("admin") = RS("login")
	Session("email") = RS("email")
	Session("nivel") = RS("nivel")
	Session("ip_admin") = Request.ServerVariables("REMOTE_ADDR")
		else
	Response.Redirect "falha.asp"
	end if 
		if  rs.eof then
	Session("yep") = True
	Session("id") = RS("id")
	Session("admin") = RS("login")
	Session("email") = RS("email")
	Session("nivel") = RS("nivel")
	Session("ip_admin") = Request.ServerVariables("REMOTE_ADDR")
		else
strCon = "DBQ=C:\Inetpub\wwwroot\emplacart\pedidos\inclusao_pedidos\bd\bd.mdb;Driver={Microsoft Access Driver (*.mdb)};"
	
Set objCon = Server.CreateObject("ADODB.Connection")
  objCon.Open strCon

  campo_duplicado = false
  campo_msg = ""

Set objRS= Server.CreateObject("ADODB.Recordset")
	objRS.CursorLocation = 3
	objRS.CursorType = 0
	objRS.LockType = 3
	strQ = "SELECT * FROM pedido Where 1 <> 1"
	objRS.Open strQ, objCon, , , &H0001
	objRS.Addnew()
	If objRS.Fields("status").properties("IsAutoIncrement") = False Then
	  objRS("status") = Trim(Request.Form("status"))
	End If
	objRS.Update
	objRS.Close
	Set objRS = Nothing
	End if
	objCon.Close
  Set objCon = Nothing
  Set objCon = Server.CreateObject("ADODB.Connection")
  objCon.Open strCon

  Set objRS= Server.CreateObject("ADODB.Recordset")
  objRS.CursorLocation = 2
  objRS.CursorType = 0
  objRS.LockType = 3
  strQ = "SELECT * FROM pedido Where 1 <> 1"
  objRS.Open strQ, objCon, , , &H0001
 FechaConexao%>

	 <BR><B>Senha Aceita</B><BR>Deseja concluir o processo ?</a><BR><BR>

	
<form id="form_incluir" name="form_incluir" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
	  <label>
	   <%If objRS.Fields("status").properties("IsAutoIncrement") = False Then%>
		<input name="status" type="checkbox" id="status" value="Concluido">
		<span class="style3">		Sim</span></label>
		   <%
Else
  Response.Write "<B>(Automático)</B>"
End If
%>	
		<input style="BACKGROUND: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #336699 0px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #336699 0px solid; COLOR: #000000; FONT-FAMILY: Verdana; FONT-SIZE: 10px" type="submit" value="Concluir" name="Submit" >
</form>
Será porque que não salva no banco de dados ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

isso tudo é so uma pagian de login?

 

nem consegui entender pois ta muito confuso

 

Faça um teste mais simples

 

Tipo assim

 

 

<%  IF Request("Login") <> "" THEN
	Dim Conn, STRSQL, RS, Login, Senha
	Login = REPLACE(Request("Login"),"'","''")
	Senha = REPLACE(Request("Senha"),"'","''")	
	SET Conn = Server.CreateObject("ADODB.Connection")
	Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("banco.mdb"))  
	STRSQL = "SELECT Nome, Senha FROM Usuario WHERE Nome = '" & Login & "' AND Senha = '" & Senha & "'"
	SET RS = Conn.Execute(STRSQL)
	IF NOT RS.EOF THEN
	   Session("Autorizado") = True
	END IF
	RS.Close()
	SET RS = Nothing
	Conn.Close
	SET Conn = Nothing
  END IF
%>

<form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post" name="Login" id="Login">
	  <table width="217" border="0" cellspacing="0" cellpadding="0">
		<tr> 
		  <td width="73"><b>Login:</b></td>
		  <td width="144"> 
			<input type="text" name="Login"></td>
		</tr>
		<tr> 
		  <td><b>Senha:</b></td>
		  <td><input type="password" name="Senha"></td>
		</tr>
		<tr> 
		  <td colspan="2"><div align="center">
			  <input type="submit" name="Submit" value="Entrar">
			</div></td>
		</tr>
	  </table>
</form>

Basicamente é so mudar os dados de conexão

 

A sua pagina tem tanta coisa que nem consegui entender a utilidade

 

Se funcionar essa parte voce continua o resto pois esxta se atrapalhando ao fazer tudo junto e fica dificil ate de te ajudar depois

 

Vamos que nem o Jack, por partes

Compartilhar este post


Link para o post
Compartilhar em outros sites

Verdade o que o Mario falou, vamos tornar esse codigo mais legivel.

 

Pra você verificar pq nao esta gravando no banco, voce da um response.write no sql, e ve se ta pegando os dados certos.

 

abs

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.