ASP Uyelik Sistemi Yapimi - 2
Uzun suren bosluktan sonra bugun, daha once basladigim paylasim dizisinin ikinci bolumune geciyoruz. Bugun daha once veritabanina kaydettigimiz kullanici bilgilerini kullanarak uye girisi sayfasini ve uye cikisi sayfasini yapacagiz.

Paylasim dizisinin ilk paylasiminda nasil uye kaydi ekleyecegimizi ve veritabani yapimizdan bahsetmistim.

Bu paylasimda ise ilk basta uye girisi icin hazirlanacak form ve ardindan verilerin kontrol edilecegi sayfayi yapacagiz.

uye_giris.htm
<form method="post" action="uye_giris.asp">
Kullanici Adi: <input type="text" name="kullanici" value size="20" class="form" style="font-family: Verdana; font-size: 8pt; color: #28333E">
<br/>
Sifre: <input type="password" name="Sifre" value size="20" class="form" style="font-family: Verdana; font-size: 8pt; color: #28333E">
<br/>
<input type="submit" value=" Gir " style="font-family: Verdana; font-size: 10px; font-weight: bold">
</form>



uye_giris.asp
'------------------- 1 --------------------
'Veritabani baglantimizi olusturuyoruz
'#######################################
DB=Server.Mappath ("uyelik.mdb")
Set ObjCon = Server.CreateObject ("ADODB.Connection")
ObjCon.Open "Provider = Microsoft.JET.OLEDB.4.0 ; Data Source = " & DB & ";"
'#######################################

'------------------- 2 --------------------
'Zararli Kodlara Karsi Guvenlik Aliyoruz
'#######################################
Function Temizle(gelenveri)
gelenveri = Replace(gelenveri ,"<","",1,-1,1)
gelenveri = Replace(gelenveri ,">","",1,-1,1)
gelenveri = Replace(gelenveri ,Chr(34),"",1,-1,1)
gelenveri = Replace(gelenveri ,Chr(39),"",1,-1,1)
gelenveri = Replace(gelenveri ,"%","",1,-1,1)
gelenveri = Replace(gelenveri ," and ","",1,-1,1)
gelenveri = Replace(gelenveri ," or ","",1,-1,1)
Temizle = gelenveri
End Function
'#######################################


'------------------- 3 --------------------
'Form Gelen Bilgiler ALiniyor
'#######################################
isim = Temizle (Request.Form ("kullanici"))
sifre = Temizle (Request.Form ("Sifre"))
'#######################################

'------------------- 4 --------------------
'Formdan Gelen Bilgiler Kontrol Ediliyor
'#######################################
if Len(isim) = 0 Then
Response.Write ("Lutfen isminizi Yaziniz !")
ElseIf Len(sifre) = 0 Then
Response.Write ("Lutfen sifrenizi yaziniz !")
Else
'#######################################


'------------------- 5 --------------------
'Kayit Setimizi Aciyoruz
'#######################################
Set ObjRs = Server.CreateObject ("ADODB.RecordSet")
ObjRs.Open ("Select * From uye Where kullanici = '" & isim & "' And sifre = '" & sifre & "'"),ObjCon,1,3
'#######################################


'------------------- 6 --------------------
'Uye Isminin ve Sifresinin Olup Olmadigini Kontrol Ediyoruz
'#######################################
if ObjRs.EOF Then
Response.Write ("Lutfen Dogru Bir Kullanici Ismi ve Sifre Giriniz !")
Else
'#######################################


'------------------- 7 --------------------
'Kullaniciya Oturum Aciyoruz
'#######################################
Session ("isim") = ObjRs ("kullanici")
Session ("sifre") = ObjRs ("sifre")
Session.TimeOut = 1000
'#######################################

'------------------- 8 --------------------
'Hersey Dogru Ise Mesaj Versin.
'#######################################
Response.Write ("Uye girisi basarili.")
'#######################################


'------------------- 9 --------------------
'Nesneleri Kapatalim
'#######################################
ObjRs.Close
Set ObjRs = Nothing
ObjCon.Close
Set ObjCon = Nothing
'#######################################


'Yukaridaki Korumalari Kapatalim
'#######################################
End if
End if
'#######################################


Burda yapilanlari anlatmak gerekirse; Ilk basta kullanicinin form araciligi ile bilgileri girmesini istedik ve sonrasinda bilgilerin kontrolu icin uye_giris.asp sayfasina yonlendirdik. Bu sayfa da ise sirasiyla (numaralari yukarida belirtilmis siradan takip edebilirsiniz.)
1- Veritabani baglantimizi kurduk.
2- Kontrolde kullanilmak uzere zararli veya hata almamizi saglayabilecek kodlarimizin temizlenmesini tanimladik.
3- Gelen bilgileri temizledik
4- Gelen bilgilerin bos olup olmadigi kontrolunu yaptik.
5- Verilerin dogrulugu icin kayit setimizi actik.
6- Veritabaninin uyusmamasi durumunda bilgilerin hatali oldugu uyarisini verdik.
7- Bilgilerin dogru olmasi durumunda kullanici adi ve sifresiyle Session(oturum) actik.
8- Giris basarili mesaji verdirdik.
9- Nesnelerimizi ve korumalarimizi kapattik.
March 15, 2009
Ayberk Atasay
ASP
7 yorum