using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlConnection mycon = new SqlConnection("server=.;database=ccsit;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
mycon.Open();
cmd.Connection = mycon;
}
protected void Button1_Click1(object sender, EventArgs e)
{
cmd.CommandText = "select count (*) from login where uname='" + TextBox1.Text + "'";
int i = (int)cmd.ExecuteScalar();
if (i == 1)
{
Response.Write("");
TextBox1.Text = "";
}
else
{
cmd.CommandText = "insert into login values ('" + TextBox1.Text + "','" + TextBox3.Text + "','"+TextBox4 .Text+"','"+RadioButtonList1 .Text+"','"+DropDownList1 .Text+"')";
cmd.ExecuteNonQuery();
Response.Redirect("signin.aspx");
}
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
}
}
Login And sign up form in Asp .net
Thursday, August 6, 2009
User login
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class signin : System.Web.UI.Page
{
SqlConnection mycon = new SqlConnection("server=.;database=ccsit;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
mycon.Open();
cmd.Connection = mycon;
}
protected void Button1_Click(object sender, EventArgs e)
{
cmd.CommandText = "select count (*) from login where uname ='" + TextBox1.Text + "' and pwd='" + TextBox2.Text + "'";
int i =(int)cmd.ExecuteScalar();
if (i == 1)
{
Session["uname"] = TextBox1.Text;
Response.Redirect("home.aspx");
}
else
Response.Write("");
TextBox1.Text = "";
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class signin : System.Web.UI.Page
{
SqlConnection mycon = new SqlConnection("server=.;database=ccsit;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
mycon.Open();
cmd.Connection = mycon;
}
protected void Button1_Click(object sender, EventArgs e)
{
cmd.CommandText = "select count (*) from login where uname ='" + TextBox1.Text + "' and pwd='" + TextBox2.Text + "'";
int i =(int)cmd.ExecuteScalar();
if (i == 1)
{
Session["uname"] = TextBox1.Text;
Response.Redirect("home.aspx");
}
else
Response.Write("");
TextBox1.Text = "";
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
}
}
Front page
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class front : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
RadioButton2.Checked = true;
RadioButton1.Checked = false;
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton2.Checked = false;
RadioButton1.Checked = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton2.Checked == true)
{
Response.Redirect("signin.aspx");
}
else
{
Response.Redirect("Admin.aspx");
}
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class front : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
RadioButton2.Checked = true;
RadioButton1.Checked = false;
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton2.Checked = false;
RadioButton1.Checked = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton2.Checked == true)
{
Response.Redirect("signin.aspx");
}
else
{
Response.Redirect("Admin.aspx");
}
}
}
Admin Sign in page
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Admin : System.Web.UI.Page
{
SqlConnection mycon = new SqlConnection("server=.;database=ccsit;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
mycon.Open();
cmd.Connection = mycon;
}
protected void Button1_Click(object sender, EventArgs e)
{
cmd.CommandText = "select count (*) from admin where adname='" + TextBox1.Text + "' and pwd='"+TextBox2 .Text +"'";
int i = (int)cmd.ExecuteScalar();
if (i == 1)
{
Session["uname"] = TextBox1.Text;
Response.Redirect("DATA VIEW.aspx");
}
else
{
//cmd.CommandText = "insert into admin values ('" + TextBox1.Text + "','" + TextBox2.Text + "')";
Response.Write ("");
TextBox1.Text = "";
}
}
}
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Admin : System.Web.UI.Page
{
SqlConnection mycon = new SqlConnection("server=.;database=ccsit;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
mycon.Open();
cmd.Connection = mycon;
}
protected void Button1_Click(object sender, EventArgs e)
{
cmd.CommandText = "select count (*) from admin where adname='" + TextBox1.Text + "' and pwd='"+TextBox2 .Text +"'";
int i = (int)cmd.ExecuteScalar();
if (i == 1)
{
Session["uname"] = TextBox1.Text;
Response.Redirect("DATA VIEW.aspx");
}
else
{
//cmd.CommandText = "insert into admin values ('" + TextBox1.Text + "','" + TextBox2.Text + "')";
Response.Write ("");
TextBox1.Text = "";
}
}
}
Subscribe to:
Posts (Atom)