Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

ASP help


Guest kerrymoralee9280

Recommended Posts

Guest kerrymoralee9280
Posted

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.

Posted

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.

Guest kerrymoralee9280
Posted

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?

Guest kerrymoralee9280
Posted
Any ideas?
Guest kerrymoralee9280
Posted

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,

Posted

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

 

http://livedocs.adobe.com/en_US/Dreamweaver/9.0/help.html?content=WSc78c5058ca073340dcda9110b1f693f21-7a11.html

 

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

 

http://livedocs.adobe.com/en_US/Dreamweaver/9.0/WSc78c5058ca073340dcda9110b1f693f21-79d1.html

 

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

 

http://livedocs.adobe.com/en_US/Dreamweaver/9.0/WSc78c5058ca073340dcda9110b1f693f21-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.

Guest kerrymoralee9280
Posted

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

of index to store the session variable. Is this in the right place? Should it be in body or in login.asp instead?
Guest kerrymoralee9280
Posted
No ideas?
Posted

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

 

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

 

I have added this to before the

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

Guest kerrymoralee9280
Posted

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

Posted

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:

 

 

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

 

 

Next somewhere at the top of the page itself before the 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.

Guest kerrymoralee9280
Posted

Thanks, :)

 

Will give that a go

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...