veritabanı adı: kitapyurdu
tablo: Kullanici
Giris Sayfası Giriş Yap Butonu
string kullanici = TxtEposta.Text;
string sifre = TxtSifre.Text;
SqlConnection baglan = new SqlConnection("Data Source=LAB3OGRTMEN\\SQLEXPRESS;Initial Catalog=kitapyurdu;Integrated Security=True");
SqlCommand sorgula = new SqlCommand("SELECT * FROM Kullanici WHERE Eposta=@KullaniciAdi AND Sifre=@Sifre", baglan);
sorgula.Parameters.AddWithValue("@KullaniciAdi", kullanici);
sorgula.Parameters.AddWithValue("@Sifre", sifre);
baglan.Open();
SqlDataReader oku = sorgula.ExecuteReader();
if (oku.Read())
{
Session["KullaniciAdi"] = oku["AdSoyad"].ToString();
Session["Yetki"] = oku["Yetki"].ToString();
Response.Redirect("Default.aspx");
}
else
hata.Visible = true;
TxtEposta.Text = "";
TxtSifre.Text = "";
TxtEposta.Focus();
oku.Close();
baglan.Close();
baglan.Dispose();
Master Sayfası Session Karşılama
protected void Page_Load(object sender, EventArgs e)
{
if (Session["KullaniciAdi"] != null)
{
LblGiris.Text = "Hoşgeldin " + Session["KullaniciAdi"].ToString();
BtnCikis.Visible = true;
}
}
protected void BtnCikis_Click(object sender, EventArgs e)
{
Session["KullaniciAdi"] = null;
Response.Redirect("Default.aspx");
}
Yönetim Sayfası Yetkilendirme
protected void Page_Load(object sender, EventArgs e)
{
if(Session["Yetki"]==null || Session["Yetki"].ToString()=="normal")
{
Response.Redirect("hata.aspx");
}
}
Bilişim Teknolojileri Kaynak Site