Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal, boa tarde!
Alguem possui um tutorial passo a passo de login e senha utilizando AJAX (ASP).
Desde já agradeço.
olha este link Um Exemplo Do Uso Do Ajax
Valeu galera!
Com as dicas mencionadas consegui fazer numa boa. muito obrigado mesmo.
abs.
eu uso sempre jquery com o plugin jquery.form, depois fica assim,
1º carregue o jquery e o plugin
2º chama-mos o nosso ficheiro que vai validar os dados via ajax
url: "login.asp",
type: "post",
alert("ok"); //faz o que entender melhor
}
else{
alert("erro") //o que quiser também
}
}
}
3º o seu form
4º o seu ficheiro asp para validar os dados neste caso o login.asp
response.buffer = true
Response.Charset="iso-8859-1"
response.contentType = "text/plain"
response.expires = 0
user=decodeutf8(request("user"))
passe=decodeutf8(request("passe"))
sql="select id from suatabela where seucampodouser like '"&user&"' and seucampopasse like '"&passe&"'"
rs.open sql,conexao
if rs.eof and rs.bof then
erro=1
else
erro=0
session.timeout = 50
session("suasessao")=rs("id")
end if
rs.close
set rs = nothing
conexao.close
set conexao = nothing
if erro=1 then
response.write "1"
else
response.write "0"
end if
não se esqueça de fazer tratamento das aspas nas variáveis usadas no sql
tem ai uma chamada da função decodeut8 isso serve para tratar problemas com acenteução
<%
' Simple functions to convert the first 256 characters
' of the Windows character set from and to UTF-8.
' Written by Hans Kalle for Fisz
' http://www.fisz.nl
'IsValidUTF8
' Tells if the string is valid UTF-8 encoded
'Returns:
' true (valid UTF-8)
' false (invalid UTF-8 or not UTF-8 encoded string)
function IsValidUTF8(s)
dim i
dim c
dim n
IsValidUTF8 = false
i = 1
do while i < len(s)
c = asc(mid(s,i,1))
if c and &H80 then
n = 1
do while i + n < len(s)
if (asc(mid(s,i+n,1)) and &HC0) <> &H80 then
exit do
end if
n = n + 1
loop
else
i = i + 1
end if
loop
IsValidUTF8 = true
end function
'DecodeUTF8
' Decodes a UTF-8 string to the Windows character set
' Non-convertable characters are replace by an upside
' down question mark.
'Returns:
' A Windows string
'
' Fiz uma pequeno ajuste porque o algoritmo gera erro quando
' o acento está no último caractere
function DecodeUTF8(s)
dim i
dim c
dim n
s = s + chr(65)
i = 1
do while i < len(s)
c = asc(mid(s,i,1))
if c and &H80 then
n = 1
do while i + n < len(s)
if (asc(mid(s,i+n,1)) and &HC0) <> &H80 then
exit do
end if
n = n + 1
loop
if n = 2 and ((c and &HE0) = &HC0) then
c = asc(mid(s,i+1,1)) + &H40 * (c and &H01)
else
c = 191
end if
s = left(s,i-1) + chr(c) + mid(s,i+n)
end if
i = i + 1
loop
s = left(s,len(s)-1)
DecodeUTF8 = s
end function
'EncodeUTF8
' Encodes a Windows string in UTF-8
'Returns:
' A UTF-8 encoded string
function EncodeUTF8(s)
dim i
dim c
i = 1
do while i < len(s)
c = asc(mid(s,i,1))
if c >= &H80 then
s = left(s,i-1) + chr(&HC2 + ((c and &H40) / &H40)) + chr(c and &HBF) + mid(s,i+1)
i = i + 1
end if
i = i + 1
loop
EncodeUTF8 = s
end function
%>