Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Varification coding

Status
Not open for further replies.

RShoe5

Programmer
Oct 24, 2006
2
US
I have a problem with some coding that I hope someone can help me with. I am very new to ASP.

I have a Intranet site that employees log into. When they do, their username and password is verified. The coding for that is:

<html>
<head>
<title>Verification Page</title>
</head>
<body>
<%
Dim adoCon
Dim strCon
Dim rsCheckUser
Dim strSQL
Dim strUserName
strUserName = Request.Form("txtUserName")
session ("strUserName") = Request.Form ("txtUserName")
Set adoCon = Server.CreateObject("ADODB.Connection")
strCon = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../fpdb/Online_Briefing_Items.mdb")
adoCon.Open strCon
Set rsCheckUser = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT qrysignin.Password FROM qrysignin WHERE qrysignin.Userid ='" & session ( "strUserName" ) & "'"
rsCheckUser.Open strSQL, strCon
If NOT rsCheckUser.EOF Then
If (Request.Form("txtUserPass")) = rsCheckUser("Password") Then
Session("blnIsUserGood") = True
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
Response.Redirect"decision_page.asp?name=" & strUserName
End If
End If

Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
Session("blnIsUserGood") = False
Response.Redirect"briefing_done_page.asp"
%>
<p>&nbsp;</p>

</body>

</html>

I have another page that once online, the employee goes to and reads information. Once the information is read and they check a box, the employee can no longer view that page. At least that is what I'm trying do, but I can't get it to work. I'm using the same coding as above but it is not picking up the username from the original sign in page. I have a session variable that displays the user's name on every page as long as they are signed in, but I can't seem to get the verification page to pick it up. Can anyone help?
 
If I were you, I'd make an "include file" that looks something like this:[tt]
<%
IF Session("strUserName") = "" THEN
Response.Redirect "login.asp"
END IF
%>
[/tt]

... and I'd include it on the top of every secure page in the web application.
 
I have this at the top of each page. Does it do the same thing?

<%
If Session("blnIsUserGood") = False or IsNull(Session("blnIsUserGood")) = True then
Response.Redirect"unauthorised_user_page.asp"
End If
%>

The code you see above is where the original login is verified. It works fine. I think the code below needs modified when I'm trying to run the verification again to allow access to another area. I want it to use the session variable or the user, not look to the original login text box. I just can't figure out how to do it.

strUserName = Request.Form("txtUserName")
session ("strUserName") = Request.Form ("txtUserName")
 
Session("blnIsUserGood") can only be Null if it is explicitly set to Null somewhere else in the code. A zero-length empty string is not the same as Null.

Rather than checking for "Falseness" it is much better to check for "Lack of "Truth" as follows:
[tt]
<%
If NOT Session("blnIsUserGood") = True Then
Response.Redirect"unauthorised_user_page.asp"
End If
%>[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top