Hi, guys. This is what I did:
code:
Dim username,password
username = Request.Form("username")
password = Request.Form("password")
If username = "" OR password = "" Then
Response.Redirect("index.asp")
Else
Dim cn,sql
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("database.mdb") &";Persist Security Info=False"
Set sql = cn.Execute("SELECT * FROM login WHERE field1 LIKE '" & username & "' AND field2 LIKE '" & password & "'")
If sql.EOF Then
Response.Write("Hey, you wrong!")
Response.Redirect("index.asp")
Else
Session("username") = username
Response.Write("Thank you, " & username & " welcome!")
End if
End if
%>
Basically this is login system. If user enter existing username and passowrd, write thanks for your login.
But if user enter wrong name or password, write "Hey, you wrong". The problem is I never see that when I enter wrong name and password. When I see code:
code:
If sql.EOF Then
Response.Write("Hey, you wrong!")
Response.Redirect("index.asp")
Else
After writing those message, ASP redirecting to index.asp. So I can see why not but I cannot know how to solve this problem. I just wanna message on the same page or Javascript alert or whatever to remind user.
Do you have any ideas how to solve this????
Hiroki Kozai