עבור לתוכן

שיפצורים אחרונים לקראת הבגרות בתיכנות אינטרנט מחר

Featured Replies

פורסם

שלומות,

בניתי סקר, קובץ שמכניס את ההצבעה למסד נתונים וקובץ שסופר הצבעות לכל אפשרות וגם נותן המחשה ויזואלית של הקולות:

http://img146.imageshack.us/my.php?image=survey1cf.jpg

הבעיה היא שכל אחד יכול להצביע בסקר ואני רוצה שאחרי שגולש הצביע שבמקום הסקר תופיע הודעה שאומרת "תודה על הצבעתך, לא ניתן להצביע פעמיים" או משהו בסגנון.

אין לי שמץ איך לגשת לזה אפילו..... אפשר אולי לבדוק ip ואז לבדוק אם הip כבר הצביע? :x

הקוד של הקובץ שמכניס הצבעה מהסקר למסד נתונים:

<% 
response.buffer = true
set c=server.createobject("adodb.connection")

DSN = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & _
Server.MapPath("/arielkarlinsky/database/database_users.mdb")
c.open dsn

sqlstring = "insert into survey values ('"&_
request.form("cpu")&"')"

c.execute sqlstring
%>
<script type="text/javascript">
alert("תודה על השתתפותך בסקר!");
location.href = '../index.asp';

</script>
<%

c.close
set c=nothing
%>

הקוד של הקובץ שסופר הצבעות בסקר וממחיש אותם באופן ויזואלי:

<%
set c=server.createobject ("adodb.connection")

DSN = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & _
Server.MapPath("/arielkarlinsky/database/database_users.mdb")
c.open dsn

set r = server.createobject("adodb.recordset")
r.activeconnection=c
sqlstring="select * from survey order by cpu"
r.open sqlstring


counter_64 = 0
counter_xp = 0
counter_other = 0
counter_noidea = 0
counter_all = 0
percent_xp = 0
counter_3 = 0
counter_4 = 0
do until r.eof


counter_all=counter_all+1
if trim(r.Fields("cpu").value) = "athlon64" then
counter_64=counter_64+1
end if
if trim(r.Fields("cpu").value) = "athlonxp" then
counter_xp=counter_xp+1
end if
if trim(r.Fields("cpu").value) = "noidea" then
counter_noidea=counter_noidea+1
end if
if trim(r.Fields("cpu").value) = "other" then
counter_other=counter_other+1
end if
if trim(r.Fields("cpu").value) = "pentium4" then
counter_4=counter_4+1
end if
if trim(r.Fields("cpu").value) = "pentium3" then
counter_3=counter_3+1
end if


r.movenext
loop
percent_xp = round((counter_xp*100/counter_all)*10)/10
percent_64 = round((counter_64*100/counter_all)*10)/10
percent_3 = round((counter_3*100/counter_all)*10)/10
percent_4 = round((counter_4*100/counter_all)*10)/10
percent_noidea = round((counter_noidea*100/counter_all)*10)/10
percent_other = round((counter_other*100/counter_all)*10)/10

response.write "<div align=right><font class=headline> תוצאות סקר </font>"
response.write "<br>"
response.write "<font class=normal> מספר ההצבעות לכל אפשרות בסקר לפי אחוזים, בסוגריים מספר ההצבעות עצמו לכל אפשרות</font></div>"
response.write "<br><br>"

response.write "<font class=normal>AMD Athlon XP: "
response.write "<br>"
for i=1 to percent_xp
response.write "<img src=images/square.jpg border=0>"
next
response.write "<font class=normal>"&percent_xp&"%("&counter_xp&")</font>"
response.write "<br><br>"

response.write "<font class=normal>AMD Athlon 64: "
response.write "<br>"
for i=1 to percent_64
response.write "<img src=images/square.jpg border=0>"
next
response.write "<font class=normal>"&percent_64&"%("&counter_64&")</font>"
response.write "<br><br>"

response.write "<font class=normal>Intel Pentium 4: "
response.write "<br>"
for i=1 to percent_4
response.write "<img src=images/square.jpg border=0>"
next
response.write "<font class=normal>"&percent_4&"%("&counter_4&")</font>"
response.write "<br><br>"

response.write "<font class=normal>Intel Pentium 3: "
response.write "<br>"
for i=1 to percent_3
response.write "<img src=images/square.jpg border=0>"
next
response.write "<font class=normal>"&percent_3&"%("&counter_3&")</font>"
response.write "<br><br>"

response.write "<font class=normal>Other: "
response.write "<br>"
for i=1 to percent_other
response.write "<img src=images/square.jpg border=0>"
next
response.write "<font class=normal>"&percent_other&"%("&counter_other&")</font>"
response.write "<br><br>"

response.write "<font class=normal>Unknown: "
response.write "<br>"
for i=1 to percent_noidea
response.write "<img src=images/square.jpg border=0>"
next
response.write "<font class=normal>"&percent_noidea&"%("&counter_noidea&")</font>"
response.write "<br><br>"

response.write "<div align=right><font class=normal>סך הכל הצבעות:"&counter_all&"</font></div>"




r.close
set r=nothing
c.close
set c=nothing

%>

עכשיו כמו שבוודאי שמתם לב, בתמונה שנתתי, בתיבה הימנית תחתונה יש מונה מבקרים, הבעיה דומה לבעיה בסקר, המונה מבקרים הוא בעצם מונה לחיצות שכל הקוד שלו הוא פשוט האפליקישן + 1, כך שהוא בעצם רץ כל פעם שמבוצעת פעולה כלשהי, מעבר לדף כלשהו או ריפרש.

אני רוצה שהמונה מבקרים באמת יהיה מונה מבקרים, הלפ anyone?

אה ושאלה כללית לסיום - מה ההבדל בין אפליקיישן לסיישן? המורה שלי הסביר לי שההבדל הוא שאפליקישן הוא גלובלי.... עוד משהו שאני צריך לדעת?

תודה לעוזרים.

פורסם

יש לך טבלאת משתמשים? יופי. כל פעם שמשתמש מצביע, תוסיף אותו לטבלה מיוחד ששומרת איזה משתמש הצביע לאיזה סקר. בנוסף, תאפשר רק למשתמשים להצביע, ובעת הצבעה תבדוק אם המשתמש לא קיים בטבלה הנוספת שיצרת.

סשן - משתנה שנשמר לכל אחד שמתחבר לאתר ונמחק כאשר הוא יוצר.

אפליקישן - משתנה שנוצר עם הפעלת השרת.

פורסם
  • מחבר

פתרון מעניין...

אבל אני בעיקרון מעוניין שלא רק משתמשים יוכלו להצביע...

יש דרך אחרת?

פורסם

אתה יכול לשמור עוגיות במחשב.

אבל אז אם המשתמש מפרמט/הולך למחשב אחר/מוחק עוגיות אז הוא יוכל להצביע שוב, וזה פשוט מאוד.

פורסם
  • מחבר

אוקיי לא חשוב, הלכתי לפי הרעיון שלך והוא התברר כמאוד יעיל באמת.

תודה רבה :xyxthumbs:

אתה יכול אולי גם לעזור בעניין המונה מבקרים? תודה מראש.

פורסם

אותו פטנט בדיוק, שומרת Cookie אצל המשתמש, ובודקת בכל פעם האם קיים אצל המשתמש ה Cookie לפני שמוסיפה למונה

פורסם
  • מחבר

ואיך אני עושה את זה? לצערי לא למדתי בבית ספר להשתמש כלל וכלל בקוקיז :kopfpatsch:

פורסם

response.cookies("cookie_name") כדי לשמור עוגייה,

request.cookies("cookie_name") כדי לקבל ערך של עוגיה.

תחפש בGOOGLE או ב w3schools יש הרבה דוגמאות.

פורסם

היתי הולך על פתרון מבוסס e-mail - ים ו- מפתחות

כל מי שנכנס למערכת צריך למסור e-mail

המערכת שלך תחולל מפתח למשל GUID את ה- GUID אתה מצמיד ל- email ב- DB

ושולח ל- email שלו לינק + ה- GUID שלו ב- QueryString לסקר

לא ניתן להפעיל את הסקר ללא GUID מוכר ב- DB

בכניסה השניה אם אותו GUID אתה כבר מזהה שזו כניסה נוספת ולא מאפשר הצבעה כפולה

נכון , גם בשיטה זו אפשר לעקוף את המערכת ולהצביע פעמיים, אבל זה יהיה הרבה יותר מסורבל כי אני אצטרך למסור כמה email - ים

ביתר הפתרונות הקלות בהצבעה כפולה, הרבה יותר גדולה, סטטיסטית תקבל הרבה יותר הצבעות כפולות בשיטות האחרות מאשר בשיטה הנ"ל

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים