Database Driven Flash Guestbook
This is the first of a series of open-source applications that I intend on releasing that take advantage of the MySQL/PHP/Flash combination. By storing the guestbook entries in a database, you will be able to more easily manage and delete entries if necessary. Also, instead of loading the entire set of entries (as I have seen many flash guestbooks do) this book loads one entry at a time which is much quicker. And it even comes with a pre-loader built in! This book is a great project for designers who are new to making flash work with the back-end.
In order to use the files and follow this tutorial, you will need access to a MySQL database and a server that supports PHP.
Setting Up The Database
I have submitted a tutorial that explains how to set up a database. It's available on flashkit as 'Setting up a MySQL database: for flash designers'. The same tutorial is also available on my home site at www.indivision.net in the fla section (chapter2 'DB4flash'). If this is your first project involving a database, I highly recomend that you follow that tutorial completely (including the setup of phpmyadmin) before attempting to continue with this tutorial.
Open the text file 'book.sql'. Cut and paste its entire contents into the query box of your phpmyadmin (see above tutorial for explanation) and click 'go'. The table will be created in your database that will eventually hold the guestbook entries.
Setting Database Variables & Uploading
Open the file called 'include.inc' located in the php directory. Enter the username, password and database name for the database that you created like so:
$DBhost = "localhost"; $DBuser = "yourUSERname"; $DBpass = "yourPASSWORD"; $DBName = "yourDATABASEname";
Now, upload the entire contents of the zip file included with this tutorial (except for the .fla file and the documentation) to your server. Be sure that the directory structure of the zip file is the same way you are uploading the book. In other words, all of the .php files and the .inc file must be in the 'php' directory which must be in the same directory as the guestbook.swf.
Final Notes
That's it. Point your URL to guestbook.html and you can enter a few test entries. Go back to your phpmyadmin or other database manager and delete the test entries.
NOTE: There is a flaw in the guestbook that becomes apparent once new entries are entered after others have been deleted. Sometimes the order of the entries gets mixed up because the new entries are placed in the spots where deleted entries used to be. It is possible to fix this problem by altering the PHP code but I wanted to keep everything simple and easier to learn from.
SECURITY NOTE: It is very important that you protect the folder where you have uploaded include.inc. If you don't, someone may get acquire access to your database and cause all kinds of problems for you. Check with your host/control panel about how to password protect a folder.
Let me know if you find this useful and please send a link if you use this guestbook on-line somewhere.
If you have any questions, please post them on the forum at INDIVISION. Good luck and I hope this helps.
| » Level Basic |
Added: : 2002-03-14 Rating: 4.69 Votes: 91 Hits: 842 |
| » Author |
| One man...one web site...one desire...one eye? |
| » Download |
| Download the files used in this tutorial. |
| Download (40 kb) |
discuss this topic to forum
