Jump to content

Find Login Name


Recommended Posts

I would like to know how to find user information when they access an ASP page to get their current user ID, computer name, IP address....Maelstorm......

Well, if you want to find there user ID, then you would need to create a few ASP programs. You would need for members to login to your website, then a save a cookie to there computer, then you would need to access and display that cookie. I dont know hwo to get the computer name, but ill have a look around, and as for the IP address, use this code:
<%  Response.Write(Request.ServerVariables("remote_addr"))%>

How do you want to display them? just wrote as plain text on a webpage? or saved to a database?Here is a very simple login script i wrote a while back. It connects to a database with a table of two fields, username and user_pass. What happens is, the user enters there username and password into a login form, that data is then saved as a variable, and the database is connected to. The program then collects the password in the database where the username relates the the username given by the user. The password collected from the database is then compared to the password provided by the user, and if the username given AND username collected = the same, and the password given AND password collected = the same, a cookie is placed on there computer and they are logged in. Else they are redirected to an error page:---------------------------------Login Form:

<form action="http://www.yourdomain.com/login.asp" method="post"><input type="text" size="40" name="username" value="username"><br><input type="password" size="40" name="password" value=""><p><input type="submit" value="Login"></form><form>

login.asp(before the HTML tags, i collected the data sent from the form, and assign it to variables:

<%  dim cusername, cpassword    cusername=request.form("username")    cpassword=request.form("password")%>

Then this is the database program:

<%	set conn=Server.CreateObject("ADODB.Connection")	conn.Provider="Microsoft.Jet.OLEDB.4.0"	conn.Open "D:\database.mdb"	set rs = Server.CreateObject("ADODB.recordset")	rs.Open "SELECT username, user_pass FROM userdata WHERE username='" & cusername & "'", conn	do until rs.EOF  	for each x in rs.Fields          if x.name="username" then  	session("con_user_session")=x.value  else  if x.name="user_pass" then  	session("con_pass_session")=x.value  end if  end if	next  	rs.MoveNext	loop	rs.close	conn.close	if session("con_user_session")=cusername AND session("con_pass_session")=cpassword then		response.cookies("acception")=1	response.cookies("iuser")=cusername	else		response.cookies("acception")=0	response.cookies("iuser")=""	end if%>

Then in the body section, i use this code to display the username given:

<%  response.write(request.cookies("iuser"))%>

Hope it helps. But that databse program is very simple, and un-secure. Im not sure what you meant about the displaying username tho.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...