38 users online (0 members and 38 guests)  


  Results 1 to 6 of 6

Related

  1. Passing username through a form    Forum: PHP Forum
    Replies: 0
  2. Passing username through a form    Forum: Javascript Forum
    Replies: 3
  3. How to Decode the data from Database using database handler?    Forum: Search Engine Optimization - SEO - Forum
    Replies: 1
  4. Retrieve Windows username    Forum: Javascript Forum
    Replies: 6
  5. Retrieve Windows username    Forum: PHP Forum
    Replies: 3
  1. #1
    hedgedive's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2003
    Posts
    1

    Getting A Username From A Database

    Hello I was just wondering how to get a username to Response.Write(strUserName) . I have it set to open with a name and password from my db/Members.mdb. I just want to know how to make it say in the middle of the HTML code to say Hello (username), Welcome To The Members Section!

    Thanks Alot,
    HedgeDiver http://www.hedgedive.tk

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi, welcome to the forums.

    Well, if you already have got the username then your best bet would be to add the username into the session object. Lets say your username from the database is rs("username") ,. then -

    Code:
    session("username") = rs("username")
    this puts the username into the session object. To write it -
    Code:
    response.write(session("username"))
    or the shortcut version
    Code:
    <%=session("username")%>
    hope that helps.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    Uh.. I think using session objects isn't a good idea unless you really need to

    Anyway,

    strsql = "SELECT UserName,Password FROM Members"
    set rsSecurity = server.createObject("ADODB.Recordset")
    rsSecurity.open strSQL,conn,3,1
    if not rsSecurity.eof then
    strUserName = rsSecurity("UserName")
    strPassword = rsSecurity("Password")
    end if
    rsSecurity.close
    set rsSecurity = nothing

    response.write "Hello " & strUserName & ", Welcome To The Members Section!"

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Um. If someones logging in, it implies they will have a session. There is nothing wrong with session objects, I would have thought they were less server-intense than calling a recordset every time you wished to write a single name.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    You're right in this case

    But then, it's not often that u use a recordset just to call up one record

    Anyway, I'm assuming that he's new to scripting and wants to learn. There are always different ways to do things, so let him decide which method suits his needs best

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Your right.

    Differing styles give more options
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread