Flash
  Home arrow Flash arrow Page 4 - Building Web Forms In Flash
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Building Web Forms In Flash
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 279
    2002-08-07

    Table of Contents:
  • Building Web Forms In Flash
  • Access Granted
  • Alien Invasion
  • Loading Up
  • Coming Back For More
  • A Fine Balance

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Building Web Forms In Flash - Loading Up


    (Page 4 of 6 )

    Next, we need to write a little ActionScript to submit the form data to a server-side script. Select the first keyframe in the Timeline, pop open the Actions panel, and add the following code to it.

    function doSubmit() { userData = new LoadVars(); userData.name = name; userData.species = species; userData.speciesType = speciesType.getValue(); userData.residence = residence.getValue(); userData.send("register.php", "", "post"); }
    Here's what this all means:

    The LoadVars() object is what actually packages the data for transmission to the server-side script...and so, the first task is to create an instance of this object.

    userData = new LoadVars();
    Once that's done, I've created object properties corresponding to the various form elements, and assigned values to them from the various input fields from the form.

    userData.name = name; userData.species = species; userData.speciesType = speciesType.getValue(); userData.residence = residence.getValue();
    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 to connect!"); 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: " . mysql_error()); // clean up mysql_close($connection); ?>
    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.

    More Flash Articles
    More By icarus, (c) Melonfire


     

       

    FLASH ARTICLES

    - 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

    BlackBerry VTS




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway