+ Post New Thread
Results 1 to 13 of 13
Web Development Thread, ASP help in Coding and Web Development; Hi, I'm creating a new site. I have it set up so a guest user says "logged in as guest". ...
  1. #1
    kerrymoralee9280
    Guest

    ASP help

    Hi, I'm creating a new site. I have it set up so a guest user says "logged in as guest". But how do I add the functionality so when a user logs in it shows their name.

    I'm guessing it's something like this is Pseudo:

    Get username from form on login page
    Find Usernames matching record in database
    Find Real Name for matching record in database
    Display Real Name on index page


    I'm stumped on this so would appreciate any help.

  2. #2
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,419
    Thank Post
    196
    Thanked 249 Times in 122 Posts
    Rep Power
    63

    Re: ASP help

    The logic you state is correct the easiest would be to get the real name of the username in the following way:

    Login page -> enter username and password -> verify login page -> checks are done against the database to ensure the username and password are correct -> if they are get the real name form the data base and add it to a session variable i.e. Session("RealName") = Record from database.

    On your index page simply place <%= Session("realname")%> and this will print out the real name of the user logged in.

    You need to remeber to destroy all session variables when they logout so if another person uses that PC it will no longer hold any information about the previous user.

  3. #3
    kerrymoralee9280
    Guest

    Re: ASP help

    That's one step closer - What I am using though is Dreamweaver to do the logon and verification steps etc. When logged on it redirects to index.asp

    I wouldn't know where to start on how to add a script that gets the username, looks up and finds their real name and adds it to a session variable.

    Can you give any more help on this?

  4. #4
    kerrymoralee9280
    Guest

    Re: ASP help

    Any ideas?

  5. #5

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,422
    Thank Post
    645
    Thanked 967 Times in 667 Posts
    Blog Entries
    2
    Rep Power
    328

    Re: ASP help

    I'd do it at the same stage that the login details are verified.

  6. #6
    kerrymoralee9280
    Guest

    Re: ASP help

    But how? What line of code would do it? I know how to pull a session variable up when you set one - I know how to do the log in and verification - I just don't know how to say look for the username text input on the login form and store is as such and such variable.

    Thanks,

  7. #7
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,419
    Thank Post
    196
    Thanked 249 Times in 122 Posts
    Rep Power
    63

    Re: ASP help

    First you will need to create a connection to the database:

    http://livedocs.adobe.com/en_US/Drea...3f21-7a11.html

    Next you will need to query the database to get the information you need:

    http://livedocs.adobe.com/en_US/Drea...3f21-79d1.html

    Then you will need to store information and get information from Seesion Variables:

    http://livedocs.adobe.com/en_US/Drea...3f21-79c7.html

    All of the above are from the current Dreamweaver Live Docs on the adobe website and should point you in the right direction.

    I use dreamweaver to do my stuff but I am a coder and normally use the likes of notepad to create pages.

  8. #8
    kerrymoralee9280
    Guest

    Re: ASP help

    Can't figure it. This is what I have:

    Login page with username and password (dreamweaver athenticates these against database).

    If correct goto index.

    Index should print username by using this line

    <%= Session("userID") %> (print that sessions userID)

    This is the code I use to try and store the session variable

    <% Session("userID") = Request.Form("username") %>

    (Make session called userID and get data from previously inputted textbox 'username')

    I have added this to before the <head> of index to store the session variable. Is this in the right place? Should it be in body or in login.asp instead?

  9. #9
    kerrymoralee9280
    Guest

    Re: ASP help

    No ideas?

  10. #10
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,419
    Thank Post
    196
    Thanked 249 Times in 122 Posts
    Rep Power
    63

    Re: ASP help

    <% Session("userID") = Request.Form("username") %>

    (Make session called userID and get data from previously inputted textbox 'username')

    I have added this to before the <head> of index to store the session variable. Is this in the right place? Should it be in body or in login.asp instead?
    This should be set after the login form has been posted but prior to the load of index.asp

  11. #11
    kerrymoralee9280
    Guest

    Re: ASP help

    So, does it need to go to a different page first then forward on to the index - where this new page sets the session ID?

    Or do I just add that code after the form? Or use something else on the login page that says "When form clicked do this..."

    Cheers fr all your help

  12. #12
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,419
    Thank Post
    196
    Thanked 249 Times in 122 Posts
    Rep Power
    63

    Re: ASP help

    So, does it need to go to a different page first then forward on to the index - where this new page sets the session ID?
    This is how I do most of my verification as I can have complex checking in place.

    Or do I just add that code after the form? Or use something else on the login page that says "When form clicked do this..."
    In your case this would be the best thing to do.

    I would add the following to your form:

    <input name="IDCheck" type="hidden" id="IDCheck" value="1" />

    Then set your form to post back to itself, so:

    <form action="THE NAME OF YOUR PAGE HERE" method="post">

    Next somewhere at the top of the page itself before the <HTML> tag add the following:

    <% if request.form("IDCheck") = 1 then%>

    ADD YOUR CHECKING CODE HERE

    <% End if %>

    The above will check to see if the form has been submitted if it has the code is run if not well just the login page is shown.

    When you do the check you will need to have another if else end if statement to do the redirect to index.asp if the login is correct and set the session variable or if it was incorrect to redirect back to the login page and if required display a message to the user.

  13. #13
    kerrymoralee9280
    Guest

    Re: ASP help

    Thanks,

    Will give that a go



SHARE:
+ Post New Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •