|
|
|
I have created this script using Flash and PHP. Data is saved and retrieved through
PHP and displayed in Flash movie in HTML format. ASP version of the same Guestbook
is available under ASP section.
Steps
=====
Start a new flash movie. Insert a new Dynamic text box and give it name txtmain and
don't forget to check the HTML option. Insert a dynamic text fields status which
will be used for displaying messages. Insert a new layer, name it action and place
following code in action window.
lowlimit = 0;
highlimit = 10;
loadVariablesNum ("guestbook.php?lowlimit="+lowlimit+"&highlimit="+highlimit, 0);
stop();
lowlimit and highlimit are the flash variables that would be send to PHP script.
First time data range from record 1 to record 10 will be displayed in HTML enabled
text box.
Insert two new button instances for up and down scrolling
For Up Button
=============
on (release) {
txtmain.scroll--;
}
For Down Button
=============
on (release) {
txtmain.scroll++;
}
Above code is self-explanatory.
Add two button instances for Next 10 and previous 10 records and add the following
code in action window.
Code for next Button
====================
on (release) { // Increase limits by 10
lowlimit = Number(lowlimit)+Number(10);
highlimit = Number(highlimit)+Number(10);
txtmain = "Processing Entries from "+lowlimit+" to "+highlimit+" Please wait ::: ";
loadVariablesNum ("guestbook.php?lowlimit="+lowlimit+"&highlimit="+highlimit, 0);
}
Code for Previous Button
========================
on (release) {
if (lowlimit == "0") {
txtmain = ":::: Nothing before Zero ::::";
}else{
lowlimit = Number(lowlimit) - Number(10); // dec. limits by 10
highlimit = Number(highlimit) - Number(10);
txtmain = "Processing Entries "+lowlimit+" to "+highlimit+" Please wait for a
while :::::: ";
loadVariablesNum ("guestbook.php?lowlimit="+lowlimit+"&highlimit="+highlimit, 0);
}
}
Add three dynamic text fields to the movie for Total entries(totalentries),Low Limit
(txtll) and High Limit (txthl) respectively.
Now Insert a new movie instance. Place four dynamic text boxes for name(textname) ,
email (txtemail) , website (txtwebsite) and comments (txtcomments). Add two buttons
for Submit and Reset.
Code for Submit Button
======================
on (release) {
if (txtname eq "") {
_root.txtmessage = "Name information missing.";
} else if (txtemail eq "") {
_root.txtmessage = "Email missing.";
} else if (txtcomments eq "") {
_root.txtmessage = "Comments missing.";
} else if (txtwebsite eq "") {
_root.txtmessage = "Enter the URL to your website";
} else {
submit= "Y"; // this variable will be used in PHP script to determine whether the
new data has submitted or not.
highlimit = 10;
lowlimit = 0;
_root.txtmain = "wait :::: Posting New Entry ::: ";
loadVariablesNum ("guestbook.php", 0, "POST"); // send variable to PHP script
_root.txtmessage = "Comments posted";
txtname1=txtname;
gotoAndStop (2);
}
}
Code for reset button
=====================
on (release) {
txtname = "";
txtemail = "";
txtWebsite = "http://";
txtcomments = "";
}
"Guest Book.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);
?>
|
|
| PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions | | | Install Flash player plug-in Categories : Flash, Java Script | | | Dynamic Calender in PHP, Javascript and HTML. Categories : PHP, Java Script, HTML and PHP, Calendar | | | Building dynamic menus with PHP & MySQL (ADO), JavaScript and CSS Categories : PHP, Databases, MySQL, Java Script, User Interface | | | Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view. Categories : PHP, PHP Classes, Java Script, AJAX, Databases | | | Zephyr: AJAX Based Framework for PHP5 Developers Categories : PHP, AJAX, Frameworks, Java Script, Web Applications | | | Array values from javascript to php Categories : PHP, Java Script, Arrays | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | Builds JavaScript that updates the contents of one selector based on another. Categories : HTML, Java Script, PHP, Complete Programs, General | | | Linked comboboxes with php-mysql & javascript Categories : PHP, Java Script, Databases, MySQL | | | This is a script that list all image files on a given directory, and displays
the thumbnails nicely formated within an HTML table. It also make use of
JavScript to open pop up windows when the users want to see the full photo. Categories : Graphics, PHP, Complete Programs, Java Script | | | The toll booth Categories : PHP, Java Script, Filesystem | | | MD5 secured login Categories : PHP, Java Script, Authentication, Security | | | Flash Detection Script with loads of features Categories : Java Script, Flash | |
|
|
|