• 0

Creating a login page in ASP.net with mysql


Question

hi im new to this ASP.net language and im using Visual Studio to do all my work.

i want to create a login page where the user enters their usename and password and it then checks it with the database(mysql) to see if its a valid user and if so proceeds to the site.

how would i go about doing this?, has someone got an example i can look at?

any help would be great!

thanks

7 answers to this question

Recommended Posts

  • 0

First you need to either have ODBC mapped to your MySQL DB or you need the MySQL .NET connector. Once you have those, you basically just want to open the connection, search to see if a record is returned matching the username and password, then have some sort of authentication token created (cookie, session var) to check and make sure that they were authenticated.

BAM that easy ;)

  • 0

ive followed that tutorial works great thanks! but how to set where to redirect the user when authorization is successful? ive got different kind of users in my database and i wanna redirect them according to their user status (i.e. admin etc).

any clues?

  • 0

been reading up about roles and added the necessary code in my web.config but in my login.aspx, how do i set wat roles the user has?

at the moment the code is just

if ((UserEmail.Value == "username@domain.com") && 
        (UserPass.Value == "password")) 
    {
      FormsAuthentication.RedirectFromLoginPage(UserEmail.Value, 
                                                PersistCookie.Checked);
    } 
    else 
    {
      lblResults.Text = "Invalid Credentials: Please try again";
    }
  }

what should i edit to set the roles?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.