Login code in c#


Code for login form ,user enter username,password this is verified from database and according to that user is logged in or invalid user message is given

Code for login form ,user enter username,password this is verified from database and according to that user is logged in or invalid user message is given
the database table is also given


Attachments

  • Login code in c# (38221-7110-Logincode-in-c.rar)
  • Related Articles

    Impersonation

    User who is responsible for running current thread can be impersonated programmatically.

    More articles: Authorization Authentication Login code

    Comments

    Author: Er. Ram Singh20 Feb 2011 Member Level: Gold   Points : 1

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.Net.Mail;

    public int select(string str, string username, string password)
    {
    int f = 0;
    cmd.CommandText = str;
    cmd.Connection = con;
    cmd.CommandType = CommandType.StoredProcedure;
    dr = cmd.ExecuteReader();
    while (dr.Read())
    {

    if (username.Trim().ToString() == dr.GetString(0).Trim().ToString() && password.Trim().ToString() == dr.GetString(1).Trim().ToString())
    {
    f = 1;
    return f;
    }

    }
    return f;
    }

    Author: Aarif Shaikh15 Oct 2014 Member Level: Bronze   Points : 0

    Code are good but i have one Query...

    When username and password is already a string type variable than why we need to convert them into string.
    in if statement.


    Thanks
    AARIF SHAIKH
    aarifshaikh4u@gmail.com



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: