Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 21st, 2004, 05:46 AM
Authorized User
 
Join Date: Jul 2004
Location: , , Turkey.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to blueguy
Default how can i handle 3 question in a survey

i have 3 questions and i want to use it in a survey
how can i get the results easily
using global.asa or database
give me an advice

  #2 (permalink)  
Old October 21st, 2004, 07:52 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

mmmm, more information needed. From what you have said:

Global.asa : No
Database : Yes

A theory that would achieve this:
1..Code a page with an HTML form allowing for users to input information
2..Post to a page (or it's self) that inserts into a table
3..Code an page that queries the table, gets records and outputs results

Wind is your friend
Matt
  #3 (permalink)  
Old October 21st, 2004, 08:07 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Mentiri, Muara, Brunei.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yea,

  Mat explained it clearly.

For any other queries post it clearly


--------------
Rajani

  #4 (permalink)  
Old October 23rd, 2004, 04:16 AM
Authorized User
 
Join Date: Jul 2004
Location: , , Turkey.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to blueguy
Default

first of all thank you for your reply
 i chose database you are right
questions with three answers
these are the codes
toll.htm
 <table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
                  <td width="10"><img src="/v3/images/tl_left.gif" width="10" height="19"></td>
                  <td background="/v3/images/tl_bg.gif" width="398" class="boxintitle">Hedef Sa#287;l#305;k Anketi </td>
                  <td width="10"><img src="/v3/images/tl_right.gif" width="10" height="19"></td>
                </tr>
              </table>
              <table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
                  <td width="117" valign="top"><div align="center">
                    <p align="left" class="boxintitle">
                    <img border="0" src="/v3/images/poll3.jpg"></p>
                  </div></td>
                  <td width="283">
                    <table width="279" border="0" cellspacing="2" cellpadding="5">
                   <form name="form" method="post" action="">
                    <tr>
                      <td colspan="3">Derginin Ekim say#305;s#305;nda, Ethem Sancak, gelece#287;e dayal#305; fikir ve &ouml;ng&ouml;r&uuml;lerini siz de#287;erli okuyucular#305;m#305;zla payla#351;t#305;. Siz de bu fikir ve &ouml;ng&ouml;r&uuml;lere kat#305;l#305;yor musunuz?</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="cevap1" value="1" checked>Evet, kat#305;l#305;yorum
                         </td>
                      <td><input type="radio" name="cevap1" value="2" >Hay#305;r, kat#305;lm#305;yorum</td>
                      <td><input type="radio" name="cevap1" value="3" >Dergiyi okumad#305;m (Dergiyi okumak istiyorum)</td>
                    </tr>
                    <tr>
                      <td colspan="3" height="76">Ayakta tedavi edilen SSK hastalarinin ila&ccedil;larini serbest eczanelerden almasi ve saglik hizmetlerinde vatandaslarin esit sosyal imkanlardan yararlanmasi g&ouml;r&uuml;s&uuml;ne katiliyor musunuz?</td>
                    </tr>
                    <tr>
                      <td><input name="cevap2" type="radio" value="1" checked>Evet, kat#305;l#305;yorum
                         </td>
                      <td><input name="cevap2" type="radio" value="2" >Hay#305;r, kat#305;lm#305;yorum</td>
                      <td><input name="cevap2" type="radio" value="3" >Kararsizim (Bu konuda bilgi edinmek istiyorum)</td>
                    </tr>
                    <tr>
                      <td colspan="3">Hedef Saglik Dergisine www.hedefim.com web sitesinden ulasabileceginizi biliyor muydunuz?</td>
                    </tr>
                    <tr>
                      <td colspan="2"><input name="cevap3" type="radio" value="1" checked>Evet, biliyorum</td>
                      <td><input name="cevap3" type="radio" value="2" >Hayir, yeni ogrendim</td>
                    </tr>
                    <tr>
                      <td colspan="3">
                        <div align="right">
                          <input name="Submit" type="submit" onClick="MM_openBrWindow('tesekkur.asp','ANKETTE&T HORN;EKK&Uuml;R','resizable=yes,width=300,height=3 00')" value="Kaydet">
                      </div></td></tr>
                  </form>
                  </table></td>
                </tr>
              </table>
and tesekkur.asp (popup window)
<%
SET dbobj=Server.CreateObject("ADODB.CONNECTION")
dbobj.open "DSN=HEDEFGENEL;UID=;PWD=;"

x=request.form("cevap1")
y=request.form("cevap2")
z=request.form("cevap3")
if x=1 then
c1=1
c2=0
c3=0
else if x=2 then
c1=0
c2=1
c3=0
else
c1=0
c2=0
c3=1
end if
end if

if y=1 then
y1=1
y2=0
y3=0
else if y=2 then
y1=0
y2=1
y3=0
else
y1=0
y2=0
y3=1
end if
end if

if z=1 then
z1=1
z2=0
z3=0
else if z=2 then
z1=0
z2=1
z3=0
else
z1=0
z2=0
z3=1
end if
end if

SQL1="Select * From Anket Where soruno=1"
SET anket=dbobj.execute(SQL1)
if not anket.eof then
cevap1top=anket("cevap1")
cevap1=cevap1top+c1
cevap2top=anket("cevap2")
cevap2=cevap2top+c2
cevap3top=anket("cevap3")
cevap3=cevap3top+c3

Top=cevap1+cevap2+cevap3
end if

SQL="Update Anket Set "
SQL=SQL & "cevap1=" & cevap1 & ","
SQL=SQL & "cevap2=" & cevap2 & ","
SQL=SQL & "cevap3=" & cevap3 & ","
SQL=SQL & "toplam=" & Top & ""
SQL=SQL & " Where soruno=1"
'response.Write(SQL)
'response.end
SET anket2=dbobj.execute(SQL)




SQL2="Select * From Anket Where soruno=2"

SET anket3=dbobj.execute(SQL2)
if not anket3.eof then
cevap1top=anket3("cevap1")
cevap1=cevap1top+y1
cevap2top=anket3("cevap2")
cevap2=cevap2top+y2
cevap3top=anket3("cevap3")
cevap3=cevap3top+y3

Top=cevap1+cevap2+cevap3
end if

SQL4="Update Anket Set "
SQL4=SQL4 & "cevap1=" & cevap1 & ","
SQL4=SQL4 & "cevap2=" & cevap2 & ","
SQL4=SQL4 & "cevap3=" & cevap3 & ","
SQL4=SQL4 & "toplam=" & Top & ""
SQL4=SQL4 & " Where soruno=2"
'response.Write(SQL)
'response.end
SET anket4=dbobj.execute(SQL4)

SQL3="Select * From Anket Where soruno=3"

SET anket5=dbobj.execute(SQL3)
if not anket5.eof then
cevap1top=anket5("cevap1")
cevap1=cevap1top+z1
cevap2top=anket5("cevap2")
cevap2=cevap2top+z2
cevap3top=anket5("cevap3")
cevap3=cevap3top+z3

Top=cevap1+cevap2+cevap3

end if

SQL5="Update Anket Set "
SQL5=SQL5 & "cevap1=" & cevap1 & ","
SQL5=SQL5 & "cevap2=" & cevap2 & ","
SQL5=SQL5& "cevap3=" & cevap3 & ","
SQL5=SQL5 & "toplam=" & Top & ""
SQL5=SQL5& " Where soruno=3"
'response.Write(SQL)
'response.end
SET anket6=dbobj.execute(SQL5)
response.Write("Ankete kat#305;ld#305;#287;#305;n#305;z için te#351;ekkür ederiz")%>

and database table(anket)
question answer1 answer2 answer3
1 0 0 0
2 0 0 0
3 0 0 0




  #5 (permalink)  
Old October 23rd, 2004, 08:35 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

blueguy

What exactly is your problem? Your troubles will be addressed faster if you post specific problem(s) this way its clear you have put in the effort to 'go as far as you can' before seeking help.

Your browser should be giving you an error? At a glace, you couldnt have made a connection with (no driver specified):

SET dbobj=Server.CreateObject("ADODB.CONNECTION")
dbobj.open "DSN=HEDEFGENEL;UID=;PWD=;"

Tip: If your UID,password,DB name etc changes you would have to change it on every page, Put these in global includes (all cut n paste) - EG:

1..Create a file called 'global.inc' and place it in a dir called 'scripts' at at the root of your web site:
--------cut n paste global.inc contents-------------------
  const uName = "someString"
  const pass = "someOtherString"
  const DBName = "HEDEFGENEL"
  const ServerName = "MachineName"
  Dim Conn
------------finish------------------------------

2..Now create a file called functions.inc in the same dir as above:
--------------function.inc contents--------------
Function GetConnectionString()
   GetConnectionString ="Provider=SQLOLEDB.1; " & _
   "Password=" & pass & "; " & _
   "Persist Security Info=True; " & _
   "UID=" & uName & "; " & _
   "Initial Catalog=" & DBName & "; " & _
   "Data Source=" & Servername & ";"
End Function
----------------finish-----------------------

3..Now at the very top of every page needing a database connection put:
---------------cut and paste------------------
<% Option Explicit %>


<% set Conn=server.createobject("ADODB.Connection")
    Conn.Open(GetConnectionString) %>
-----------------finish-----------------------------

To see the results of your full connection string you can: response.write GetConnectionString()

What you have just done is created a place for all your global constants and a place for all your functions, this way you can tweak these globaly. When you have a dev site and a live site with different connection details this is in valuable.






Wind is your friend
Matt
  #6 (permalink)  
Old October 24th, 2004, 05:19 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

As a side note: It may be a good idea to rename those .inc files to .asp files.

For the end result, there is no difference. However, .inc files can be requested directly by the browser and are not parsed by the Web server, while .asp page *are* parsed.

This means that something like this:

const pass = "someOtherString"

will end up as clear text in the browser when you request an .inc file. Not a very comforting thought....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: I'll Be Yours by Placebo (Track 9 from the album: Sleeping with Ghosts) What's This?
  #7 (permalink)  
Old October 24th, 2004, 06:41 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Good day Imar

Wow, I did not know that - this would make .inc files are a fairly serious security risk. I have just tryed it, sure enough there is the full contents of my .inc files layed out in the browser. I guess the person looking for the contents would have to know the name/path of the .inc files.

Out of curiosity;
These cant be seen in the source, if directory browsing is turned off what other way can they identify the name/path of the file(s)?

Cheers for the info, very vey useful - I will no longer use .inc's files

Wind is your friend
Matt


Similar Threads
Thread Thread Starter Forum Replies Last Post
Language Survey jminatel Beginning PHP 0 August 28th, 2007 09:48 PM
Survey Engine anitafn2005 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 February 18th, 2007 01:56 AM
Survey engine anitafn2005 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 October 8th, 2006 04:17 PM
Survey App Question flsimmons BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 May 26th, 2006 03:14 PM
Survey Question! NeedASP Classic ASP Databases 0 April 9th, 2004 12:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.