sagat
08-25-2004, 11:58 PM
Hi all, i am having problems with the login script: this is the validate script:
<%
'Save the entered username and password
Username = Request.Form("Username")
Password = Request.Form("Password")
'Build connection with database
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("netteh.mdb")
set rs = server.CreateObject ("ADODB.Recordset")
'Open record with entered username
rs.Open "SELECT * FROM Students where Username='"& Username &"'", conn, 1
'If there is no record with the entered username, close connection
'and go back to login with QueryString
If rs.recordcount = 0 then
rs.close
conn.close
set rs=nothing
set conn=nothing
Response.Redirect("login.asp?login=namefailed")
end if
'If entered password is right, close connection and open mainpage
if rs("password") = Password then
Session("name") = rs("Firstname")
rs.Close
conn.Close
set rs=nothing
set conn=nothing
Response.Redirect("default.asp")
'If entered password is wrong, close connection
'and return to login with QueryString
else
rs.Close
conn.Close
set rs=nothing
set conn=nothing
Response.Redirect("login.asp?login=passfailed")
end if
%>
I have another question: how do you display sessions like for example the username and how do you display tables on the screen? I know in coldfusion there is usually an application file that usually contains sessions built in. Any help with the login script or a new one and the other question would be great.
Thanx
<%
'Save the entered username and password
Username = Request.Form("Username")
Password = Request.Form("Password")
'Build connection with database
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("netteh.mdb")
set rs = server.CreateObject ("ADODB.Recordset")
'Open record with entered username
rs.Open "SELECT * FROM Students where Username='"& Username &"'", conn, 1
'If there is no record with the entered username, close connection
'and go back to login with QueryString
If rs.recordcount = 0 then
rs.close
conn.close
set rs=nothing
set conn=nothing
Response.Redirect("login.asp?login=namefailed")
end if
'If entered password is right, close connection and open mainpage
if rs("password") = Password then
Session("name") = rs("Firstname")
rs.Close
conn.Close
set rs=nothing
set conn=nothing
Response.Redirect("default.asp")
'If entered password is wrong, close connection
'and return to login with QueryString
else
rs.Close
conn.Close
set rs=nothing
set conn=nothing
Response.Redirect("login.asp?login=passfailed")
end if
%>
I have another question: how do you display sessions like for example the username and how do you display tables on the screen? I know in coldfusion there is usually an application file that usually contains sessions built in. Any help with the login script or a new one and the other question would be great.
Thanx