To ad log in credentials to a page, accessed by a database. Would you just check a user table in the database that stores lets say, UID, UserName, UserPW and see if there credentials exist? If so, how would you do that?

Also, how would you keep track if they are logged in on each page?

Basically, this is the part of my assignment I am trying to do.

"In order to add, edit, delete cars, the user must log in using credentials that are stored in the database. You must also keep track of whether the person is logged in on every page."

Recommended Answers

All 2 Replies

Hi V;
You can use membership and data control for that.Or else after validating the user existence u can retrive that username or userId from database to frontend and then store it inside a session .Then Pass the session to every page where u want.

if(txtuserName.Text == "Jigsaw" && txtPassword == "aa")
{
  FormsAuthentication.RedirectFromLoginPage(txtuserName.Text,false);
}

// if correct credentitals then you go to default.aspx page or default page
//you have provided in your web.config file

//once you reach the default.aspx page, go to code behind in Page_Load Event

// Try this

if(Request.IsAuthenticated)
{
   Response.Write(User.Identity.Name);
}
else
{
  // Redirect to Login Page
}

// in web.config keep Authentication Mode = Forms
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.