Ziyaretçi Defteri Yapımı

Öncelikle ana sayfamızı hazırlayalım.

Ana sayfamızın kodlarını default.asp olarak kayıt edelim..

Kod:

<html>

<head>
<meta http-equiv="Content-Language" content="tr">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<title>Ttasarim.net | Ziyaretçi Defteri</title>
</head>

<body background="bg.jpg">
<center>

<div style="position: absolute; width: 687px; height: 439px; z-index: 1; left: 359px; top: 62px" id="layer1">
<table border="1" width="686" height="422" style="border-width: 0px">
<tr>
<td height="21" width="686" style="border-style: none; border-width: medium" valign="top">
<p align="center">| Ziyarçi Defteri |</td>
</tr>
<tr>
<td height="34" width="686" style="border-style: none; border-width: medium" valign="middle" bgcolor="#CC99FF">
<p align="center"><a href="deftere_yaz.asp">
<span style="text-decoration: none"><font color="#000000">
<a href="deftere_yaz.asp?islem=ekle">
<span style="text-decoration: none"><font color="#000000">Deftere Yaz
</font></span></a></font></span></a>
<span style="text-decoration: none"><font color="#000000">&nbsp;</font></span>|
<a href="yonetim.asp"><font color="#000000">
<span style="text-decoration: none">Yönetim Paneli</span></font></a></td>
</tr>
<tr>
<td height="359" width="686" style="border-style: none; border-width: medium" valign="top" bgcolor="#CCCCFF"><!--#include file="mesaj.asp"--></td>
</tr>
</table>
<table border="1" width="682" height="11" style="border-width: 0px" cellspacing="0" cellpadding="0">
<tr>
<td height="11" width="682" style="border-style: none; border-width: medium" bgcolor="#CC99FF">
<p align="center"><font size="2">Copright</font><font size="2">
</font><span lang="en"><font size="2" face="Times New Roman">©
ttasarim.net | 2011</font></span></td>
</tr>
</table>
</div>
</center>
</body>

</html>


Evet taslak olarak ana sayfamız oluştu. Sıra geldi bir veri tabanı oluşturmaya. Veri tabanımıza ziyaretçimizin bilgilerini göndereceğiz. Bunlar Adı, soyadı, e-maili, web sitesi, mesajı olacak. Linkte verdiğim dosyadaki veri tabanında mevcuttur.

Veri tabanımızda hazır olduktan sonra sıra ziyaretçimizin mesaj göndereceği alanı oluşturmaya geldi. Bu sayfamızı da deftere_yaz.asp olarak kayıt edelim.

Kod:

<%
islem = request.querystring("islem")
' gelen bilgiyi alıyoruz ve ilgili bölüme gönderiyoruz..
if islem = "" then
call kayit
else
if islem = "ekle" then
call ekle
end if
end if
%>
<% sub ekle %>
<body background="bg.jpg">

<form method="POST" action="deftere_yaz.asp">
<p>&nbsp;</p>
<p>&nbsp;</p><center>
<table border="1" width="475" height="229" style="border-width: 2px; " cellspacing="0" cellpadding="0" bordercolor="#000000">
<tr>
<td height="10" width="475" style="border-style: none; border-width: medium" colspan="2" bgcolor="#CC99FF">
<p align="center"><font size="5"><b>Deftere Yaz</b></font></td>
</tr>
<tr>
<td height="28" width="174" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
<p align="right">Adınızı:</td>
<td height="28" width="301" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
<input type="text" name="ad" size="30"></td>
</tr>
<tr>
<td height="33" width="174" style="border-style: none; border-width: medium">
<p align="right">Soy Adınız:</td>
<td height="33" width="301" style="border-style: none; border-width: medium">
<input type="text" name="soyad" size="30"></td>
</tr>
<tr>
<td height="25" width="174" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
<p align="right">E-Mail:</td>
<td height="25" width="301" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
<input type="text" name="email" size="30"></td>
</tr>
<tr>
<td height="25" width="174" style="border-style: none; border-width: medium">
<p align="right">Web Siteniz:</td>
<td height="25" width="301" style="border-style: none; border-width: medium">
<input type="text" name="website" size="30"></td>
</tr>
<tr>
<td height="51" width="174" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
<p align="right">Mesajınız:</td>
<td height="51" width="301" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
<textarea rows="5" name="mesaj" cols="34"></textarea></td>
</tr>
<tr>
<td height="21" width="174" style="border-style: none; border-width: medium" bgcolor="#CC99FF">
<input type="submit" value="Gönder" name="B1" style="float: right"></td>
<td height="21" width="301" style="border-style: none; border-width: medium" bgcolor="#CC99FF"><input type="reset" value="Sıfırla" name="B2"></td>
</tr>
</table></center>
<p align="center">&nbsp;</p>
<p align="center">
&nbsp;</p>
<p align="center">
&nbsp;</p>
<p align="center">
&nbsp;</p>
<p align="center">
&nbsp;</p>
<p align="center">&nbsp;</p>
</p>
</form>
<% end sub %>
<% sub kayit %>
<%
Set Tech = Server.CreateObject("ADODB.Connection")
Tech.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("veritabani/zd.mdb")

ad = Request.Form ("ad")
soyad = Request.Form ("soyad")
email = Request.Form ("email")
website = Request.Form ("website")
mesaj = Request.Form ("mesaj")

Set Rs = Server.CreateObject ("ADODB.RecordSet")
StrSql = "Select * from zd"
Rs.Open StrSql, Tech, 1, 3

'doldurulmamis form kutucuklarini doldurulmasini istiyoruz


Rs.AddNew
Rs("ad")=ad
Rs("soyad")=soyad
Rs("email")=email
Rs("website")=website
Rs("mesaj")=mesaj

Rs.Update
Response.Write"Mesajınız başarılı bir şekilde gönderildi ! ! !"
Rs.close
Set Rs = Nothing
Response.Redirect "default.asp"
%>
<% end sub %>


Evet şimdi mesaj yazabileceğimiz sayfamızda tamam şimdi ana sayfamızdaki deftere yaz linkimize deftere_yaz.asp?islem=ekle diye köprü atıyoruz.

deftere_yaz.asp sayfamızda tamam olduğuna göre ziyaretçi defterimizi kontrol edebileceğimiz yönetim panelimizi yapalım ben yönetim paneline şifre koymadım siz dilerseniz ki mutlaka bir şifresi olsun yaparsınız.

şimdi yonetim.asp olarak aşağıda verdiğim kodları kayıt ediniz.


Kod:

</head>
<body background="bg.jpg">
<center>

&nbsp;<p></p>
<p><font size="5"><b>Defter Yönetim</b></font></p>

<%
'buradan başlıyoruz ve veritabanının yolunu gösteriyoruz..
Set Tech = Server.CreateObject("ADODB.Connection")
Tech.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("veritabani/zd.mdb")

Set Rs = Server.CreateObject("ADODB.Recordset")
StrSql = "Select * from zd "
Rs.Open StrSql, Tech, 1, 3

Do while not Rs.eof 'yukarıdaki tablonun ilgili satırındaki tüm kayıtları sıralamak için döngü oluşturuyoruz
%>
<p> </p>
<center>
<table border="2" width="786" height="186" cellspacing="0" cellpadding="0" bordercolor="#000000">
<tr>
<td height="40" width="109" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
Adı:</td>
<td height="40" width="569" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC"><%=rs("ad")%></td>
<td height="40" width="90" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">&nbsp;</td>
</tr>
<tr>
<td height="32" width="109" align="left" style="border-style: none; border-width: medium">
Soyadı:</td>
<td height="32" width="569" align="left" style="border-style: none; border-width: medium"><%=rs("soyad")%></td>
<td height="32" width="90" align="left" style="border-style: none; border-width: medium" bgcolor="#CC99FF">&nbsp;</td>
</tr>
<tr>
<td height="31" width="109" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
E-mail:</td>
<td height="31" width="569" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC"><%=rs("email")%></td>
<td height="31" width="90" align="left" style="border-style: none; border-width: medium" bgcolor="#CC99FF">
<p align="center"><font color="#FF0000">
<a href="sil.asp?id=<%=rs("id")%>"><font color="#FF0000">
<span style="text-decoration: none">SİL</span></font></a></font></td>
</tr>
<tr>
<td height="35" width="109" align="left" style="border-style: none; border-width: medium">
Web Sitesi</td>
<td height="35" width="569" align="left" style="border-style: none; border-width: medium"><%=rs("website")%></td>
<td height="35" width="90" align="left" style="border-style: none; border-width: medium" bgcolor="#CC99FF">&nbsp;</td>
</tr>
<tr>
<td height="36" width="109" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">
Mesajı:</td>
<td height="36" width="569" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC"><%=rs("mesaj")%></td>
<td height="36" width="90" align="left" style="border-style: none; border-width: medium" bgcolor="#CCCCCC">&nbsp;</td>
</tr>
</table>
</center>

<%
've döngümüzü bititriyoruz
Rs.MoveNext
Loop
%>
<td width="69%" bgcolor="#C0C0C0">&nbsp;</td>
<td width="18%" bgcolor="#C0C0C0">&nbsp;</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="9%" id="AutoNumber2">
<tr>
<td width="28%" height="19">&nbsp;</td>
</tr>
<tr><center>
<td width="28%" bgcolor="#C0C0C0">
<p align="center"> <b><a href="default.asp"><font color="#333333">Ana Sayfa</font></a></b></p>
</td>
</tr>
</table>
</body></html>

<p align="center">&nbsp;</p>





Yönetim sayfamızın içerisinde sil linkimiz var. Sil komutunun çalışması için sil.asp adında bir sayfamızın olması gerek. O zaman verdiğim kodları sil.asp olarak kayıt ediniz.

Kod:

<% Response.Buffer = True %>

<%
Set Tech = Server.CreateObject("ADODB.Connection")
Tech.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("veritabani/zd.mdb")

id = Request("id")
Set publication = Server.CreateObject("ADODB.RecordSet")
SQL_delete = "DELETE from zd WHERE id="&id&""
publication.open SQL_delete,Tech,1,3

Response.Redirect Request.serverVariables("HTTP_REFERER")
%>



Evet, ziyaretçi defterimizin büyük bir bölümü bitti. Şimdi veri tabanından çektiğimiz mesajları mesaj.asp'ye aktaralım. Mesaj.asp ise default.asp'mize include edelim.

mesaj.asp kodları bu sayfa adıyla kayıt ediniz.


Kod:

<body bgcolor="#FFFFFF">

<center>
<%
Set Tech = Server.CreateObject("ADODB.Connection")
Tech.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("veritabani/zd.mdb")

zd = Request.Form ("zd")

Set Rs = Server.CreateObject ("ADODB.RecordSet")
StrSql = "Select * from zd order by id desc"
Rs.Open StrSql, Tech, 1, 3
%>
<table border="1" width="487" height="32" style="border-width: 0px">
<tr>


<%Do while not Rs.eof 'yukarıdaki tablonun ilgili satırındaki tüm kayıtları sıralamak için döngü oluşturuyoruz
%>

<center>
<table border="1" width="606" height="115" style="border-width: 2px; " bordercolor="#CC66FF" cellspacing="0" cellpadding="0">
<tr>
<td height="19" width="109" style="border-style: none; border-width: medium" align="left" bgcolor="#CC99FF">
<font color="#FFFFFF">Adı:</font></td>
<td height="19" width="493" style="border-style: none; border-width: medium" bgcolor="#FFFFFF"><%=rs("ad")%> </td>
</tr>
<tr>
<td height="19" width="109" style="border-style: none; border-width: medium" align="left" bgcolor="#CC99FF">
<font color="#FFFFFF">Soyadı:</font></td>
<td height="19" width="493" style="border-style: none; border-width: medium" bgcolor="#FFFFFF">
<%=rs("soyad")%> </td>
</tr>
<tr>
<td height="19" width="109" style="border-style: none; border-width: medium" align="left" bgcolor="#CC99FF">
<font color="#FFFFFF">E-Mail:</font></td>
<td height="19" width="493" style="border-style: none; border-width: medium" bgcolor="#FFFFFF"><%=rs("email")%> </td>
</tr>
<tr>
<td height="19" width="109" style="border-style: none; border-width: medium" align="left" bgcolor="#CC99FF">
<font color="#FFFFFF">Web Sitesi:</font></td>
<td height="19" width="493" style="border-style: none; border-width: medium" bgcolor="#FFFFFF"><%=rs("website")%> </td>
</tr>
<tr>
<td height="35" width="109" style="border-style: none; border-width: medium" align="left" bgcolor="#CC99FF">
<font color="#FFFFFF">Mesajı:</font></td>
<td height="35" width="493" style="border-style: none; border-width: medium" bgcolor="#FFFFFF"><%=rs("mesaj")%> </td>
</tr>
</table>
</center>
<table border="1" width="657" height="6" style="border-width: 0px">
<center><tr>
<td height="2" width="657" style="border-style: none; border-width: medium" align="center"></td>
</tr></center>
</table>

<%
've döngümüzü bititriyoruz
Rs.MoveNext
Loop
%>

</center>
</table>