- Katılım
- 26 Mar 2024
- Mesajlar
- 3,145
- Tepkime puanı
- 149
- Puanları
- 63
- İlişki Durumunuz
- Sizene
- Burcunuz
- Balık
- Takım
- Fenerbahçe
- Konu Yazar
- #1
Asp Anket Yapımı
db.asp diye kaydedin...
Kod Alanı:
db bağlantımızı yapıyoruz...
<%
Set Bag = Server.CreateObject("ADODB.Connection")
Bag.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/db.mdb")
Set Rs=Server.CreateObject("Adodb.Recordset")
%>
anket.asp diye kaydedin...
Kod Alanı:
<!-- #include file="db.asp" -->
<%
Sorgu = "select * from anket "
Rs.Open Sorgu bag 1 3
%>
<%
if Request.Cookies("magnet")("anket")="oylandi" then ' cookie mizi alıyorz eğer cookiemizi önceden atmışsak
response.write "Bu Anketi Daha Önce Oylamışsınız..." ' bu yazı çıkıyor
end if
%>
<%
if Request.Cookies("magnet")("anket") = "" then ' cookie mizi alıyorz eğer cookiemiz boş veya hiç yoksa anket çıkacak
%>
<FORM action="anket_oyla.asp" name="anket" method="post" target="anket" onsubmit="javascript:void window.open('anket_oyla.asp''''width=450height= 280scrollbars=0')">
<table border=0 bordecolor=efefef width="201">
<tr><td width="195"><font face="Verdana" size="1"><b><%=rs("soru")%></b><font size="1" face="Verdana"><br></td></tr>
<% if rs("alan1")="" then ' eğer alan1 yani 1. anketimiz boşsa
response.write "" ' boş çıkartıyoruz ki adam boş yazdığında boş anket çıkmasın
END İF
%>
<% if rs("alan1")<>"" then ' eğer boştan büyük veya küçükse yani bp değilse anketimizi yazdırıyoruz
' AYNI İŞLEMLER ALTTAKİLER İÇİNDE GEÇERLİ
%></font>
<tr><td width="195"><font face="Verdana" size="1"><input type="radio" name="Anket" value="<%=rs("alan1")%>"><%=rs("alan1")%></td></tr>
<% end if %>
<% if rs("alan2")="" then
response.write ""
end if
%>
<% if rs("alan2")<>"" then %> </font>
<tr><td width="195"><font face="Verdana" size="1"><input type="radio" name="Anket" value="<%=rs("alan2")%>"><%=rs("alan2")%></td></tr>
<%end if%>
<% if rs("alan3")="" then
response.write ""
end if
%>
<% if rs("alan3")<>"" then %> </font>
<tr><td width="195"><font face="Verdana" size="1"><input type="radio" name="Anket" value="<%=rs("alan3")%>"><%=rs("alan3")%></td></tr>
<%end if%>
<% if rs("alan4")="" then
response.write ""
end if
%>
<% if rs("alan4")<>"" then %> </font>
<tr><td width="195"><font face="Verdana" size="1"><input type="radio" name="Anket" value="<%=rs("alan4")%>"><%=rs("alan4")%></td></tr>
<%end if%>
<% if rs("alan5")="" then
response.write ""
end if
%>
<% if rs("alan5")<>"" then %> </font>
<tr><td width="195"><font face="Verdana" size="1"><input type="radio" name="Anket" value="<%=rs("alan5")%>"><%=rs("alan5")%></td></tr>
<%end if%> </font>
<tr><td width="195"><font size="1" face="Verdana"><input name="submit" type="submit" value=" Oy Ver " class="binyedi"></font></td></tr>
</form>
</table>
<%end if%><%
rs.close
set rs=nothing
bag.close
set bag=nothing
%>
<br><br>
<a href="anket_sonuc.asp" target="sonuc" alt="Anket Sonuçları" onclick="javascript:void window.open('anket_oyla.asp''''width=450height= 280scrollbars=0')"><font face="Tahoma" style="font-size: 8pt" color="#197c8f" >Anket Sonuçları</a>
anket_oyla.asp diye kaydedin...
Kod Alanı:
<!-- #include file="db.asp" -->
<%
id = request.querystring("id")
Sorgu = "select * from anket "
Rs.Open Sorgu bag 1 3
%>
<%
Response.Cookies("magnet")("anket") = "oylandi" ' cookie mizi atıyoruz
response.cookies("magnet").expires=Now()+30 ' pc de kalma süresünü 30 gün yapıoruz...
%>
<%
anket=Request.Form ("Anket") ' formdan gelen anketi alıyoruz
Select Case Anket ' ve seçtiriyoruz
Case rs("alan1") ' eğer işaretli alan1 ise
rs("alan1_1")=rs("alan1_1")+1 ' alan1_1 i 1 arttırıyoruz ve diğerleride aynı...
rs.update
Case rs("alan2")
rs("alan2_2")=rs("alan2_2")+1
rs.update
Case rs("alan3")
rs("alan3_3")=rs("alan3_3")+1
rs.update
Case rs("alan4")
rs("alan4_4")=rs("alan4_4")+1
rs.update
Case rs("alan5")
rs("alan5_5")=rs("alan5_5")+1
rs.update
End Select 'seçme bittikten sonra anket_sonuc.asp ye yallah
response.redirect "anket_sonuc.asp"
%>
anket_sonuc.asp diye kaydeedin...
Kod Alanı:
<!-- #include file="db.asp" -->
<%
Set sonuclar = Server.Createobject("ADODB.Recordset")
sql = "select * from anket"
sonuclar.open sql bag 1 3
TOPLAMOY = sonuclar("alan1_1") + sonuclar("alan2_2") + sonuclar("alan3_3") + sonuclar("alan4_4") + sonuclar("alan5_5") ' tüm sonuçları tolluyoruz ve yoplam oy belirliyoruz
%>
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr><td colspan=2><b>
<font face="Verdana" size="1"><p>Anket Sonuçları</font></b></p>
<font face="Verdana" size="2" color="000000">Anket Sorusu :<b> <%=sonuclar("soru")%></b><br><br>Cevaplar : </font></td></tr>
<%if sonuclar("alan1_1") = "0" then 'eğer alan1_1 eşit 0 ise
sonuc1 = "0" ' ekrana 0 yazdırıoruz
else 'değilse
sonuc1 = sonuclar("alan1_1") / TOPLAMOY 'toplam oyu alan1_1 bölüyoruz
sonuc1 = sonuc1 * 100
If Len(sonuc1) > 4 Then ' aynıları altada geçerli
sonuc1 = Left(sonuc1 4) & ""
end if
end if
%><font size="1" face="Verdana"> </font>
<tr><td width=50%>
<font face="Verdana" size="2" color="blue"><%=sonuclar("alan1")%></font><font size="1" face="Verdana">
</font><font size="1" face="Verdana">: ( <%=sonuclar("alan1_1")%> Oy ) </font> </td>
<td width=50%> <font face="Verdana" size="1">%<%=sonuc1%> <img height="12" width="<%=sonuc1%>%" src=images/derece1.gif></font></td></tr>
<%if sonuclar("alan2_2") = "0" then
sonuc2 = "0"
else
sonuc2 = sonuclar("alan2_2") / TOPLAMOY
sonuc2 = sonuc2 * 100
If Len(sonuc2) > 4 Then
sonuc2 = Left(sonuc2 4) & ""
end if
end if
%> </font>
<tr><td width=50%>
<font face="Verdana" size="2" color="blue"><%=sonuclar("alan2")%></font><font size="1" face="Verdana">
</font><font size="1" face="Verdana">: ( <%=sonuclar("alan2_2")%> Oy ) </font> </td>
<td width=50%> <font face="Verdana" size="1">%<%=sonuc2%> <img height="12" width="<%=sonuc2%>%" src=images/derece2.gif></font></td></tr>
<%if not sonuclar("alan3") = "" then %>
<%if sonuclar("alan3_3") = "0" then
sonuc3 = "0 "
else
sonuc3 = sonuclar("alan3_3") / TOPLAMOY
sonuc3 = sonuc3 * 100
If Len(sonuc3) > 4 Then
sonuc3 = Left(sonuc3 4) & ""
end if
end if
%> </font>
<tr><td width=50%>
<font face="Verdana" size="2" color="blue"><%=sonuclar("alan3")%></font><font size="1" face="Verdana">
</font><font size="1" face="Verdana">: ( <%=sonuclar("alan3_3")%> Oy ) </font> </td>
<td width=50%> <font face="Verdana" size="1">%<%=sonuc3%> <img height="12" width="<%=sonuc3%>%" src=images/derece3.gif></font></td></tr>
<%end if%>
<%if not sonuclar("alan4") = "" then %>
<%if sonuclar("alan4_4") = "0" then
sonuc4 = "0 "
else
sonuc4 = sonuclar("alan4_4") / TOPLAMOY
sonuc4 = sonuc4 * 100
If Len(sonuc4) > 4 Then
sonuc4 = Left(sonuc4 4) & ""
else
end if
end if
%> </font>
<tr><td width=50%>
<font face="Verdana" size="2" color="blue"><%=sonuclar("alan4")%></font><font size="1" face="Verdana">
</font><font size="1" face="Verdana">: ( <%=sonuclar("alan4_4")%> Oy ) </font> </td>
<td width=50%> <font face="Verdana" size="1">%<%=sonuc4%> <img height="12" width="<%=sonuc4%>%" src=images/derece4.gif></font></td></tr>
<%end if%>
<%if not sonuclar("alan5") = "" then %>
<%if sonuclar("alan5_5") = "0" then
sonuc5 = "0 "
else
sonuc5 = sonuclar("alan5_5") / TOPLAMOY
sonuc5 = sonuc5 * 100
If Len(sonuc5) > 4 Then
sonuc5 = Left(sonuc5 4) & ""
else
end if
end if
%> </font>
<tr><td width=50%>
<font face="Verdana" size="2" color="blue"><%=sonuclar("alan5")%></font><font size="1" face="Verdana">
</font><font size="1" face="Verdana">: ( <%=sonuclar("alan5_5")%> Oy ) </font> </td>
<td width=50%> <font face="Verdana" size="1">%<%=sonuc5%> <img height="12" width="<%=sonuc5%>%" src=images/derece5.gif></font></td></tr>
<%end if%> </font>
<tr><td colspan=2><center><font face="Verdana" size="1">Toplam Oy : <%=TOPLAMOY%></font></center></td></tr>
<tr><td colspan=2>
<p align="center"><b><font face="Verdana" size="1" color="#008000">
<a href="JavaScriptnClick= window.close()" style="text-decoration: none">Pencereyi Kapat</a></font><font face="Verdana" size="1"> </font>
</b>
<font face="Verdana" size="1">
<br><br></font></p></td></tr>
</table>
admin bölümündeyiz...
anket_admin.asp diye kaydedin
Kod Alanı:
<!--#include file="db.asp"-->
<%
if request("update")<>"" then
soru=request("soru")
alan1=request("alan1")
alan2=request("alan2")
alan3=request("alan3")
alan4=request("alan4")
alan5=request("alan5")
alan1_1=request("alan1_1")
alan2_2=request("alan2_2")
alan3_3=request("alan3_3")
alan4_4=request("alan4_4")
alan5_5=request("alan5_5")
Rs.ActiveConnection = bag
Sorgu="SELECT * FROM anket"
rs.open Sorgubag32
rs.update "soru"soru
rs.update "alan1"alan1
rs.update "alan2"alan2
rs.update "alan3"alan3
rs.update "alan4"alan4
rs.update "alan5"alan5
rs.update "alan1_1"alan1_1
rs.update "alan2_2"alan2_2
rs.update "alan3_3"alan3_3
rs.update "alan4_4"alan4_4
rs.update "alan5_5"alan5_5
rs.close
set rs=nothing
Response.write "Güncellendi..."
else
end if
%>
<!--#include file="db.asp"-->
<%
Rs.ActiveConnection = bag
Rs.Open="Select * from anket "
%>
<form action="anket_admin.asp" method="post">
<table border="0" cellpadding="2" cellspacing="2" width="833">
<tr>
<td width="290" align=right><b>
<font face="Tahoma" style="font-size: 8pt">Anket Sorusu</font></b><font face="Tahoma" style="font-size: 8pt" color="#000000"><b>
:</b></td>
<td colspan=2 width="529">
<input type="text" name="soru" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("soru")%>" size="88" maxlength="50"> </td>
</tr>
<tr>
<td width="290" align=right><b>
<font face="Tahoma" style="font-size: 8pt">Alan1</font></b><font face="Tahoma" style="font-size: 8pt" color="#000000"><b>
:</b></td>
<td width="220">
<input type="text" name="alan1" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan1")%>" size="41" maxlength="250"> </td>
<td width="603">
<input type="text" name="alan1_1" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan1_1")%>" size="41" maxlength="50"> </td>
</tr>
<tr>
<td width="290" align=right><b>
<font face="Tahoma" style="font-size: 8pt">Alan2</font></b><font face="Tahoma" style="font-size: 8pt" color="#000000"><b>
:</b></td>
<td width="220">
<input type="text" name="alan2" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan2")%>" size="41" maxlength="250"> </td>
<td width="603">
<input type="text" name="alan2_2" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan2_2")%>" size="41" maxlength="50"> </td>
</tr>
<tr>
<td width="290" align=right><b>
<font face="Tahoma" style="font-size: 8pt">Alan3</font></b><font face="Tahoma" style="font-size: 8pt" color="#000000"><b>
:</b></td>
<td width="220">
<input type="text" name="alan3" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan3")%>" size="41" maxlength="250"> </td>
<td width="603">
<input type="text" name="alan3_3" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan3_3")%>" size="41" maxlength="50"> </td>
</tr>
<tr>
<td width="290" align=right><b>
<font face="Tahoma" style="font-size: 8pt">Alan4</font></b><font face="Tahoma" style="font-size: 8pt" color="#000000"><b>
:</b></td>
<td width="220">
<input type="text" name="alan4" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan4")%>" size="41" maxlength="250"> </td>
<td width="603">
<input type="text" name="alan4_4" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan4_4")%>" size="41" maxlength="50"> </td>
</tr>
<tr>
<td width="290" align=right><b>
<font face="Tahoma" style="font-size: 8pt">Alan5</font></b><font face="Tahoma" style="font-size: 8pt" color="#000000"><b>
:</b></td>
<td width="220">
<input type="text" name="alan5" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan5")%>" size="41" maxlength="250"> </td>
<td width="603">
<input type="text" name="alan5_5" style="font-size: 8pt" color="#003366" value="<%Response.Write RS("alan5_5")%>" size="41" maxlength="50"> </td>
</tr>
<input type="hidden" name="update" value="1">
<%
rs.close
set rs=nothing
bag.close
set bag=nothing
%>
<tr><td colspan=2 width="503"><center><INPUT TYPE="submit" VALUE=" Kaydet " style="BACKGROUND-COLOR: #FFFFFF; BORDER-BOTTOM: #486078 1px inset; BORDER-LEFT: #486078 1px inset; BORDER-RIGHT: #486078 1px inset; BORDER-TOP: #486078 1px inset; COLOR: #486078; FONT-FAMILY: Verdana; FONT-SIZE: 8pt"> <INPUT type="Button" VALUE=" İptal " OnClick='history.go( -1 );return true;' style="BACKGROUND-COLOR: #FFFFFF; BORDER-BOTTOM: #486078 1px inset; BORDER-LEFT: #486078 1px inset; BORDER-RIGHT: #486078 1px inset; BORDER-TOP: #486078 1px inset; COLOR: #486078; FONT-FAMILY: Verdana; FONT-SIZE: 8pt"></td></tr>
</table>
</form>