473,320 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

help with code please

Hi,

I have an asp page that needs to create 2 different cookies: one for
the admin and one for the user. The code that I have to work with was
created by someone else. the page first requires to login and if
username and password match then the user is redirected to the same
page where he sees details of his message.

What I have to do is this: in my db i have a table called users with
the fields u_id, u_password and access. Access can either be admin or
user.
In my asp page i have to create 2 cookies. The thing is that i am not
sure how to do it. now i am using hardcode. i am not calling the
access field from the table but i am writing access="admin". However
the page that is meant to receive the data from the first page where i
created the cookie doesn't work. no matter if access =admin or user it
always gives me the message "access is user".

Here is the code for the 1st page:
dim access

MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?"
+ Request.QueryString
MM_valUsername=CStr(Request.Form("Username"))

If MM_valUsername <> "" Then
MM_fldUserAuthorization=""
MM_redirectLoginSuccess="myAds.asp"
MM_redirectLoginFailed="myAds.asp"

MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_connDUclassified_STRING
MM_rsUser.Source = "SELECT U_ID, U_PASSWORD, ACCESS"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source =
MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM USERS WHERE U_ID='" &
MM_valUsername &"' AND U_PASSWORD='" & CStr(Request.Form("Password"))
& "'"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open

If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then

' username and password match - this is a valid user
'DIM ACCESS
' access=(mm_rsuser.fields.item ("ACCESS").value)
DIM U_ID
DIM U_PWORD
ACCESS="admin"
'---create user cookie
if ACCESS<>"admin" then
Response.Cookies("UserCookie")("Username") =
Request.Form("UserName")
Response.Cookies ("UserCookie")("Password")=Request.Form ("Password")
Response.Cookies("UserCookie").Path = "/"
Response.Cookies ("UserCookie").expires =dateadd("h",1,now())
Response.Write(Request.Cookies("UserCookie")("User name"))
Response.Write (Request.Cookies("UserCookie")("Password"))

'---end user cookie
else
'create admin cookie

Response.Cookies("adminCOOKIE")("ADMINusername") =
Request.Form("UserName")
Response.Cookies ("adminCOOKIE")("ADMINPassword")=Request.Form
("Password")
Response.Cookies("adminCOOKIE").Path = "/"
Response.Cookies ("adminCOOKIE").expires =dateadd("h",1,now())
Response.Write(Request.Cookies("adminCOOKIE")("ADM INusername"))
Response.Write (Request.Cookies("adminCOOKIE")("ADMINPassword"))

'---end admin cookie

end if

Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then

Session("MM_UserAuthorization") =
CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization ).Value)
Else
Session("MM_UserAuthorization") = ""

End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")

End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If

MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)

End If
%>

2nd page:
<%
Dim Username
Dim Password
Dim adminU
Dim adminP
Username = ((Request.Cookies("UserCookie")("Username")))
Password = ((Request.Cookies("UserCookie")("Password")))
adminU =
((Request.Cookies("adminCOOKIE")("ADMINusername")) )
adminP =
((Request.Cookies("adminCOOKIE")("ADMINPassword")) )
If Username <> "" And Password <> "" Then
Response.Write("username:" + Username + "<BR>")
Response.Write("password:" + Password + "<BR>")
Response.Write("Access is User" + "<BR>")

ElseIf adminU <> "" And adminP <> "" Then
Response.Write("adminusername:" + adminU + "<BR>")
Response.Write("adminpassword:" + adminP + "<BR>")
Response.Write("Access is admin")
End If
%>
Jul 19 '05 #1
0 1503

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
13
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error...
2
by: tuan_vandyk | last post by:
Hi I desperately need help with my project. Theoretically everything should work bu it just isn't. Please email me for a copy of the project's source code. It was made in Turbo C++ 5. Please if...
1
by: glenn123 | last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. basically i need to read in a text file... shown below H H,E,L E,B,F B,A,C A,null,null c,null,D
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.