Step 1:- open .net click new>website>
Step 2:-design your .aspx page just like fig 1.0
Step 3:- open CS file of That page
copy past the below code
public partial class _Default : System.Web.UI.Page
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString);
SqlDataReader dr;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnregister_Click(object sender, EventArgs e)
{
Session.Clear();
Session.Abandon();
Response.Redirect("register.aspx");
}
protected void btnlogin_Click(object sender, EventArgs e)
{
if (txtusername.Text == "")
{
Label1.Text = "You must Login with valid username/password";
}
else
{
string userid = txtusername.Text.Replace("'", "''");
string pwd = txtpassword.Text.Replace("'", "''");
cmd = new SqlCommand("select * from table name where email_id ='" + userid + "' and password='" + pwd + "'", con);
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["name"] = dr["name"].ToString();
con.Close();
Response.Redirect("welcomeuser.aspx");
else
{
con.Close();
Label1.Text = "You must Login with valid username/password";
}
if (con.State != null)
{
con.Close();
}
}
}
}
Step 2:-design your .aspx page just like fig 1.0
copy past the below code
public partial class _Default : System.Web.UI.Page
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString);
SqlDataReader dr;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnregister_Click(object sender, EventArgs e)
{
Session.Clear();
Session.Abandon();
Response.Redirect("register.aspx");
}
protected void btnlogin_Click(object sender, EventArgs e)
{
if (txtusername.Text == "")
{
Label1.Text = "You must Login with valid username/password";
}
else
{
string userid = txtusername.Text.Replace("'", "''");
string pwd = txtpassword.Text.Replace("'", "''");
cmd = new SqlCommand("select * from table name where email_id ='" + userid + "' and password='" + pwd + "'", con);
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["name"] = dr["name"].ToString();
con.Close();
Response.Redirect("welcomeuser.aspx");
else
{
con.Close();
Label1.Text = "You must Login with valid username/password";
}
if (con.State != null)
{
con.Close();
}
}
}
}
0 comments:
Post a Comment