Home arrow Flash arrow Page 2 - Building Web Forms In Flash

Access Granted - Flash

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.

  1. Building Web Forms In Flash
  2. Access Granted
  3. Alien Invasion
  4. Loading Up
  5. Coming Back For More
  6. A Fine Balance
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 323
August 07, 2002

print this article


Obviously, that was a very primitive example, though one that did demonstrate the concept of integrating user-supplied data with a server-side script via a Flash movie. Now, how about a twist?

This next example uses the data entered into a Flash form to query a database and return a list of matches. In order to create the form, create a new Button symbol, in much the same way as you created the one on the previous page. Name the form variable within the symbol "q", and add a copy of the instance to the Flash movie.

Once that's done, add some ActionScript to the symbol instance, referencing the server-side script "search.php" - this time, use POST to send the form variables to the script.

on (keyPress "<Enter>") { getURL ("search.php", "", "POST"); }
All that's left now is to write the PHP script "search.php". Here's what mine looks like:

<html> <head><basefont face="Arial"></head> <body> <h2>Search Results</h2> <ol> <? // search.php // get query term $query = trim($_POST['q']); // open connection to database $connection = mysql_connect("localhost", "user", "pass") or die ("Unable to connect!"); mysql_select_db("db20139a") or die ("Unable to select database!"); // formulate and execute query $query = "SELECT * FROM data WHERE tag LIKE '%$query%' OR keyword LIKE '%$query%'"; $result = mysql_query($query) or die("Error in query: " . mysql_error()); // get record while($row = mysql_fetch_object($result)) { echo "<li>"; echo "<a href=go.php?id=$row->id>$row->tag</a>"; echo "<br>$row->title"; echo "<p>"; } // clean up mysql_close($connection); ?> </ol> </body> </html>
Here's what the search box looks like,

and here's a sample results page.

>>> More Flash Articles          >>> More By icarus, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- An Overview of Flash and ActionScript
- Building Web Forms In Flash
- Building Data-Driven Flash Movies
- Flash 101 (part 6): The Final Countdown
- Flash 101 (part 5): Spiralling Out Of Control
- Flash 101 (Part 4): Don't Touch Me!
- Flash 101 (part 3): Bouncing Around

Developer Shed Affiliates


Dev Shed Tutorial Topics: