|
|
|
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);
?>
|
|
| A Complete table(ADD,EDIT,VIEW,DELETE) management System PHP,MYSQL, JAVASCRIPT Categories : PHP, MySQL, Java Script, Databases | | | filesystem Show Files Script Categories : PHP, Filesystem, Java Script | | | Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item. Categories : PHP Classes, PHP, Java Script, DHTML | | | Zephyr: AJAX Based Framework for PHP5 Developers Categories : PHP, AJAX, Frameworks, Java Script, Web Applications | | | PHP Calendar Categories : PHP, Calendar, Date Time, Java Script, CSS | | | Tree Menu Dynamic (+Static) with Loading in Progress.. Categories : PHP, Java Script, HTML and PHP | | | OverEasy - PHP generated JavaScript to do mouseovers on
your pages. Modify one file and one function does it all
for you! Categories : PHP, Java Script, HTML and PHP, MySQL | | | A Simple sign up script with PHP and JavaScript validations. Categories : PHP, Java Script, MySQL, Databases | | | Protect your mailto: email addresses from bots Categories : PHP, Email, Java Script | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | Array values from javascript to php Categories : PHP, Java Script, Arrays | | | Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page. Categories : PHP, AJAX, HTML and PHP, Java Script | | | PHP3 generated gif / javascript mouseover. Categories : PHP, Java Script, MySQL | | | A simple configuration file editor to ease you life in setting up php applications. Reads variables from a given file automatically and displays current value. New value will be written to file after submit. Categories : PHP, Filesystem, Regexps, Java Script | | | PHP Array to Javascript Object Categories : PHP, Arrays, Java Script | |
|
|