WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Classic guest book made with PHP and Flash
Categories : PHP, Flash, Java Script Click here to Update Your Picture
Pradeep Mamgain
Date : Jul 16th 2002
Grade : 3 of 5 (graded 6 times)
Viewed : 23459
File : phpguestbook.zip
Images : No Images for this code example.
Search : More code by Pradeep Mamgain
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

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);
?>




PHP Array to Javascript Object
Categories : PHP, Arrays, Java Script
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
Protect your mailto: email addresses from bots
Categories : PHP, Email, Java Script
Tree Menu Dynamic (+Static) with Loading in Progress..
Categories : PHP, Java Script, HTML and PHP
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
Local Time clock and Server time usign PHP and JavaScript
Categories : PHP, Java Script, Date Time, Beginner Guides
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
Alert in JavaScript and Trace in Flash Action script are two commands that I find very much useful for tracking and debugging errors in my scripts. Unfortunately, there is no such option in PHP.
Categories : PHP, Java Script, Debugging
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
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
Popup window creator for images on the Fly.
Categories : PHP, GD image library, Java Script
Install Flash player plug-in
Categories : Flash, Java Script
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions