In addition to building animation clips on the fly, Flash canalso be used to build simple Web forms to collect user data on your Website. This article demonstrates the process, showing you how to buildsimple Flash forms and link them to server-side scripts for furtherprocessing.
Note my usage of the getValue() methods to acquire the value
of the selected items in both the radio button set and the list box. ActionScript also offers the getSelectedItems() function, which can be used to retrieve the selected items in a multiple-select list box (not demonstrated here).
Once all the form data has been loaded into the object, the send() method is used to submit this data to a server-side script - in this case, "register.php".
userData.send("register.php", "", "POST");
Pretty simple - the variables from the form are sent to the
script "register.php" via POST. Let's see what that script does.
$name = $_POST['name'];
$species = $_POST['species'];
$speciesType = $_POST['speciesType'];
$residence = $_POST['residence'];
// open connection to database
$connection = mysql_connect("localhost", "user", "pass") or die ("Unable
mysql_select_db("db20139a") or die ("Unable to select database!");
// formulate and execute query
$query = "INSERT INTO aliens (alien_name, species_name, species_type,
residence_type) VALUES ('$name', '$species', '$speciesType',
'$residence')"; $result = mysql_query($query) or die("Error in query: "
// clean up
This should be familiar to you if you've programmed in PHP
before - the data entered by the user into the form is extracted from the special $_POST array and plugged into an SQL query template. A connection to the database server is initiated, this SQL query is then executed, and the user data is inserted into the database.