Hii friends
I am creating a web application Now there are only two users who will login to the system
the two users are Admin and staff
When Admin logins he is directed to Admin.aspx
and when staff login he is directed to Staff.aspx
I have created a database Table in which I have four fields
ID,UserName,passWord,User_type
for admin it is 1,Admin,Admin,Administrator
and for staff it is 2,Staff,Staff,StaffUser
How can i do this ,,,Uptil now I have created a simple login page the code is as follows...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionstring"].ConnectionString);
con.Open();
string cmdStr = "select count(*) from Registration where UserName='"+TextBox1.Text+"'";
SqlCommand Checkuser = new SqlCommand(cmdStr, con);
int temp = Convert.ToInt32(Checkuser.ExecuteScalar().ToString());
if (temp == 1)
{
string cmdStr2 = "Select password from Registration where UserName='"+TextBox1.Text+"'";
SqlCommand pass = new SqlCommand(cmdStr2, con);
string password = pass.ExecuteScalar().ToString();
con.Close();
if (password == TextBox2.Text)
{
Session["New"] = TextBox1.Text;
Response.Redirect("Secure.aspx");
}
else
{
Label1.Visible = true;
Label1.Text = "Invalid Password";
}
}
else
{
Label1.Visible = true;
Label1.Text = "Invalid UserName";
}
}
}