Library tutorials & articles
Classic Guestbook made with Flash and ASP/PHP
By Pradeep Mamgain, published on 05 Apr 2002
Page 3 of 4
- Introduction
- More Flash Code
- The PHP Code
- The ASP Code
The PHP Code
Below is the PHP code. The guestbook data is stored in guestbook.txt. For the ASP code, go to the next page.
guestbook.php
//If data is submitted
If (isset($submit)){
if ($submit=="Y"){
$datestamp =(date ("dS F Y ( h:i:s A )",time())); //current
date
$fpn=@fopen("guestbook.txt","a+"); //open guest book
txt for append mode.
@flock ($fpn,2);
$rec = "Name: <b>$txtname</b><br>Email:
<b><u><a href=\"mailto:$txtemail\">$txtemail</a></u></b><br>Website:
<b><u><a href=\"$txtwebsite\" target=\"_blank\">$txtwebsite</a></u></b><br>Comments:
<b>$txtcomments</b><br><i>Posted on: $datestamp" . "\n";
// store data in HTML format
$fw=fwrite($fpn,$rec);
@flock($fpn,3);
@fclose($fpn);
}
}
//Read Data from Guest Book Database
//Store all entries in a Array.
$fp=@fopen("guestbook.txt","r");
@flock ($fp,2);
$garr=array();
while ($line=@fgets($fp,1024)){
array_push($garr,$line);
}
$totalent=count($garr)-1;
if ($totalent<0){
$totalent=0;
}
if($highlimit>$totalent){
$highlimit=$totalent;
}
//Following code will be used for sending variables to PHP script.
print "&txtll=$lowlimit&txthl=$highlimit&totalentries=$totalent&txtmain=" ;
//If u remember txtll,txthl,totalentries and txtmain are dyanamic text boxes
we have created in flash movie.
if (count($garr)==0){
print "<br><br><b> :::: Nothing to display ::::
</b>";
exit();
}
$ar=array_reverse($garr); // reverse the array
$garr=array();
for($i=$lowlimit;$i<=$highlimit;$i++){ // filter the records between lowlimit
and highlimit
if (!$ar[$i]) {
print "<br><br><b>::: Nothing Below This :::</b>";
exit;
}
print $ar[$i];
print "<br><br>";
}
@flock($fp,3);
@fclose($fp);
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.