Library tutorials & articles
Classic Guestbook made with Flash and ASP/PHP
By Pradeep Mamgain, published on 05 Apr 2002
Page 4 of 4
- Introduction
- More Flash Code
- The PHP Code
- The ASP Code
The ASP Code
This is the ASP code... The data is stored in guestbook.mdb, with a table called tbguest, and two fields; gid and gcomments.
Guestbook.asp
dim filename 'name of database file
dim maxfld 'record counter
dim cmtStr ' comment string
filename=server.mappath("/") & "\" & "guestbook.mdb"
// path to access database
'Set connection string for access database
cs="Provider=Microsoft.jet.oledb.3.51;"
cs=cs & "Persist Security info=false;"
cs=cs & "data source="
cs=cs & filename & ";"
set adocon=server.createobject("adodb.connection") 'create
connection object
adocon.open cs 'open connection
'fetch variables from flash
txtname=request.form.item("txtname")
txtemail=request.form.item("txtemail")
txtwebsite=request.form.item("txtwebsite")
txtcomments=request.form.item("txtcomments")
'Create recordset and get no of records in the database.
set rs_max_value=adocon.execute("select max(val(gid)) as x from
tbguest")
maxfld=rs_max_value.fields("x")
'Increment the no by one.
if isnull(maxfld) then
maxfld=1
else
maxfld=maxfld+1
end if
rs_max_value.close ' close the recordset object.
'If new data is submitted
if request.form.item("submit1")="Y" then
'create a new string in HTML format using variables
cmtstr = "Name: <b>" & txtname & "</b><br>Email:
<b><u><a href=" & "'" & "mailto:"
& txtemail & "'" & ">" & txtemail &
"</a></u></b><br>"
cmtstr = cmtstr & "Website: <b><u><a href=" &
"'" & txtwebsite & "'" & " target="
& "'" & "_blank" & "'" & ">"
& txtwebsite & "</a></u></b><br>"
cmtstr = cmtstr & "Comments: <b>" & txtcomments &
"</b><br>"
cmtstr = cmtstr & "<i>Posted on: " & Now() & "<br>"
dim commandobject
dim insertionstr
set commandobject=server.createobject("adodb.command") 'create
a command object
set commandobject.activeconnection=adocon // set active connection to the command
object
insertionstr="insert into tbguest (gid,gcomments) values (?,?)"
' sql query for insertion
commandobject.commandtext=insertionstr
commandobject.prepared=true
commandobject.parameters.append commandobject.createparameter("gid",3,,1000)
commandobject.parameters.append commandobject.createparameter("gcomments",200,,500)
'Assign values to command objects
commandobject("gid")=maxfld
commandobject("gcomments")=cmtstr
commandobject.execute 'execute the query
set commandobject=nothing // destroy the command object
end if
dim llimit
dim hlimit
llimit=request.form.item("lowlimit")
hlimit=request.form.item("highlimit")
'Calculate total entries in Access
dim sqlstr
dim flashstr
sqlstr="select max(gid) as x from tbguest"
set rs_flash=adocon.execute(sqlstr)
totalent=rs_flash.fields("x")
rs_flash.close
'Following code is for displaying entries from lowlimit to highlimit
if totalent>0 then
sqlstr="select * from tbguest order by gid desc"
set rs_flash=adocon.execute(sqlstr)
dim strflash
rs_flash.movefirst
if totalent>=hlimit then
hlimit=totalent
end if
upto=llimit-1
j=0
for j=1 to upto
rs_flash.movenext
next
i=0
for i=1 to (hlimit-llimit)+1
if rs_flash.eof then exit for
strflash=strflash & rs_flash.fields("gcomments")
rs_flash.movenext
next
strflash=strflash & "<br><br>" & " :::::::::::::
Nothing Below This ::::::::::::::: "
else
strflash=":: Nothing to Display ::"
rs_flash.close
end if
response.write("&txtll=" & llimit & "&txthl="
& hlimit & "&totalentries=" & totalent & "&txtmain=")
response.write(strflash) // variables for flash movie.
adocon.close // destroy the connection
Related articles
Related discussion
-
Beginning from scratch
by Slicksim (1 replies)
-
How to modularize CSS menus
by Slicksim (2 replies)
-
What technology / Framework would you propose
by James Crowley (2 replies)
-
ASP VS PHP
by paulfp (9 replies)
-
What would motivate you to change your job?
by kovshenin (4 replies)
Related podcasts
-
Java Posse #212 - Oracle Developer Tools Interview
Interview with Ted Farrell about Oracle Developer Tools Fully formatted shownotes can always be found at http://javaposse.com We talk to Ted Farrell (and at the end Duncan Mills) about the Oracle Java developer tools, the new Oracle 11g product stack, Oracle's work on JSRs, the future of the ...
Related jobs
-
Senior Web Developer - Luxembourg
in Luxembourg (€45K-€70K per annum)
I've managed to get PHP working on my site and the PHP version seems to be working ok
Hi there
I've created a new directory on my site called guestbook and in it have placed the files:
guestbook.swf
guestbook.html [containing the swf file above]
asguest.asp
guestbook.txt
guestbook.mdm
I have created a new ODBC on my server and this is the path to the database:
htdocs\guestbook\guestbook.mdb
the link to the guestbook is http://www.eskymo.co.uk/guestbook/guestbook.html and is in it's original state as I wanted to test it worked before re-designing the interface. When checking the swf file online and entering my details and message it does the following:
says thankyou for signing up in the right hand panel and in the left panel reads 'wait ::: posting new entry' but nothing else happens even when refreshing the page.
Am I doing something wrong - do i need to alter the path to the databse in the script at all even though all the files are sitting in the same directory. As there is no working demo accompanying the tutorial I have no idea what it is supposed to do, even though i presume the data i've inputted should appear int he left panel.
Can anyone help me with this - i feel like such a numpty - It's the first time i'm dealing with databases and not sure if i'm missing something.
cheers
e
I have had a problem running the guestbook. Whenever I try to add an entry, I get error messages pointing to the highlimit, lowlimit and in variables, saying they are undefined.
Can anyone tell me what I am doing wrong??
I'd appreciate it if you emailed me
Thanks..
This thread is for discussions of Classic Guestbook made with Flash and ASP/PHP.