Creating a guestbook in Flash using PHP script and a MySQL database
Setting up the database
You will need to have access to a server running PHP and MySQL. If you use another database, replace the MySQL database functions that I use in the PHP script with the database functions for the other database i.e. PostgresSQL, MSSQL.
First create two tables in the database:
# This table will hold the guestbook entries.
# Table structure for table `flashgb`
#
CREATE TABLE flashgb (
id int(4) NOT NULL auto_increment,
name varchar(20) NOT NULL default '',
Second steps in creating a Flash - PHP guestbook
Processing variables sent from Flash to PHP.
The guestbook script that process the variables is very simple. It checks to see if all the variables have a value. If one of the variables is empty, the script redirects the browser to the HTML page with the Flash movie, otherwise it prints the variables.
PHP Code:
<?php
if (($homepage == "") || ($email == "") || ($name == "") || ($comments == "")) {
header("Location: guestbook.html");
exit;
}
?>
<HTML> <HEAD> <TITLE>Guestbook Submission information</TITLE> </HEAD>
First steps in creating a Flash - PHP guestbook
Sending variables from Flash to PHP.
I decided to try my hand at creating a Flash SWF (Flash 5) that would interact with PHP.
I created a very simple contact form in Flash:
The first frame of the Flash movie has a stop action on the frame, four input text fields and two buttons (send and clear) on the stage.
The input text fields:
The name, homepage and email input text fields should have the 'Single Line' and 'BorgerBg' options selected.